Hadi1989

Untitled

Jul 6th, 2018
601
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.13 KB | None | 0 0
  1. <?php
  2.     require_once 'conn.php';
  3.    
  4.     if(ISSET($_POST['search'])){
  5.         //$query = $conn->query("SELECT * FROM `member` WHERE (`lastname` LIKE '%".$_POST['search']."%') OR (`city` LIKE '%".$_POST['search']."%') ");
  6.         $query = $conn->query("SELECT * FROM `member` WHERE (`firstname` LIKE '%".$_POST['search']."%') OR (`lastname` LIKE '%".$_POST['search']."%') OR (`city` LIKE '%".$_POST['search']."%') OR (`postal_code` LIKE '%".$_POST['search']."%') ") ;
  7.  
  8.         $row = $query->num_rows;
  9.        
  10.         if($row > 0){
  11.             $output = "";
  12.                 $output .= "
  13.             <center><h3>Search Result</h3></center>
  14.             <table class='table'>
  15.                 <thead>
  16.                     <tr>
  17.                         <th>Name</th>
  18.                         <th>City</th>
  19.                         <th>Postal Code</th>
  20.                     </tr>
  21.                 </thead>
  22.                 <tbody>
  23.             ";
  24.            
  25.             while($fetch = $query->fetch_array()){
  26.                 $output .= "
  27.                     <tr>
  28.                         <td>".$fetch['firstname']." ".$fetch['lastname']."</td>
  29.                         <td>".$fetch['city']."</td>
  30.                         <td>".$fetch['postal_code']."</td>
  31.                     </tr>
  32.                 ";
  33.             }
  34.            
  35.             $output .="
  36.                 </tbody>
  37.             </table>
  38.             ";
  39.            
  40.             echo $output;
  41.         }else{
  42.             echo "<center><h4>Search Not Found!</h4></center>";
  43.         }
  44.            
  45.     }
  46. ?>
Advertisement
Add Comment
Please, Sign In to add comment