Guest User

Untitled

a guest
Jan 5th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.72 KB | None | 0 0
  1. if(isset($_POST['search'])) {
  2.     $s_robot    = $_POST['searchRobot'];
  3.     $s_date     = $_POST['searchDate'];
  4.     $s_code     = $_POST['searchErrorcode'];
  5.     $s_position     = $_POST['searchCoordinate'];
  6.     $s_nick     = $_POST['searchLoggedBy'];
  7.                    
  8.     //Check witch query to select (make it simplier in futher releases)
  9.     if(!empty($s_robot)) {
  10.         $searchQuery = "SELECT * FROM robot_error WHERE robot = '$s_robot' ORDER BY id DESC";
  11.     }
  12.     elseif(!empty($s_date)) {
  13.         $searchQuery = "SELECT * FROM robot_error WHERE date = '$s_date' ORDER BY id DESC";
  14.     }
  15.     elseif(!empty($s_code)) {
  16.         $searchQuery = "SELECT * FROM robot_error WHERE error_code = '$s_code' ORDER BY id DESC";
  17.     }
  18.     elseif(!empty($s_position)) {
  19.         $searchQuery = "SELECT * FROM robot_error WHERE position = '$s_position' ORDER BY id DESC";
  20.     }
  21.     elseif(!empty($s_nick)) {
  22.         $searchQuery = "SELECT * FROM robot_error WHERE logged_by = '$s_nick' ORDER BY id DESC";
  23.     }
  24.     $query = mysql_query($searchQuery);
  25.                
  26.     while($s_info = mysql_fetch_object($query)) {
  27.         //First get information from new_robot_error table
  28.         $e_robot    = $s_info->robot;
  29.         $e_date     = $s_info->date;
  30.         $e_position     = $s_info->position;
  31.         $e_error    = $s_info->error_code;
  32.         $e_observation  = $s_info->observation;
  33.         $e_solution     = $s_info->solution;
  34.         $e_downtime     = convert_sec_2_hours($s_info->downtime);
  35.                    
  36.         //Get information from other tables
  37.         //Get robot status
  38.         $e_status = get_robot_status($e_robot);
  39.         //Check if error is at port
  40.         $getPort    = mysql_query("SELECT port_number FROM ports WHERE port_coordinate = '$e_position'");
  41.         $portInfo   = mysql_fetch_array($getPort);
  42.         $e_port     = $portInfo['port_number'];
  43.         //Get errorsource
  44.         $getErrorsource = mysql_query("SELECT error_message, error_source FROM errorcodes WHERE error_code = '$e_error'");
  45.         $errorInfo = mysql_fetch_array($getErrorsource);
  46.         $e_message = $errorInfo['error_message'];
  47.                                    
  48.                                    
  49.                                
  50.         //Custom icons depending on robot status
  51.         if($e_status == 0) {
  52.             $class = "<tr class='gradeX'>";
  53.             $field = "<td><img src='css/images/icons/light/cross.png'></td>";
  54.         }
  55.         else {
  56.             $class = "<tr class='gradeA'>";
  57.             $field = "<td><img src='css/images/icons/light/tick.png'></td>";
  58.         }  
  59.         //Print result
  60.         echo $class."\n";
  61.         echo $field."\n";
  62.         echo "<td>".$e_date."</td>\n";
  63.         echo "<td>".$e_robot."</td>\n";
  64.         echo "<td>".$e_position."</td>\n";
  65.         echo "<td>".$e_port."</td>\n";
  66.         echo "<td>".$e_error."</td>\n";
  67.         echo "<td>".$e_message."</td>\n";
  68.         echo "<td><textarea class='roboterror' data-autogrow='true'>".$e_observation."</textarea></td>\n";
  69.         echo "<td><textarea class='roboterror' data-autogrow='true'>".$e_solution."</textarea></td>\n";
  70.         echo "<td>".$e_downtime."</td>\n";
  71.         echo "</tr>\n";
  72.                                
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment