Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4. <?php
  5. $q=$_GET["keyword"];
  6.  
  7. $host = "localhost";
  8. $user = "X31251643";
  9. $password = "X31251643";
  10.  
  11. $con = mysql_pconnect($host, $user, $password);
  12. if (!$con) {
  13.     die('Could not connect to database: ');
  14.     }
  15.    
  16. $dbname = "X31251643";
  17. mysql_select_db($dbname);
  18.  
  19. $query="SELECT * FROM Products
  20. WHERE ItemID = '$q'
  21. OR ItemType = '$q'
  22. OR ItemName = '$q'";
  23.  
  24. $result = mysql_query($query);
  25.  
  26. echo "<table border='1'>
  27. <tr>
  28. <th>itemID</th>
  29. <th>ItemType</th>
  30. <th>ItemName</th>
  31. <th>ItemDescription</th>
  32. <th>ItemPrice</th>
  33. </tr>";
  34.  
  35. while ($row = mysql_fetch_array($result)) {
  36.     foreach($row as $data) {
  37.    
  38.         echo "<tr>";
  39.         echo "<td> ".$data['ItemID']." </td>";
  40.         echo "<td> ".$data['ItemType']." </td>";
  41.         echo "<td> ".$data['ItemName']." </td>";
  42.         echo "<td> ".$data['ItemDescription']." </td>";
  43.         echo "<td> ".$data['ItemPrice']." </td>";
  44.         echo "</tr>";
  45.     }
  46.   }
  47. echo "</table>";
  48.  
  49. mysql_close();
  50.  
  51. ?>
  52. </body>
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement