Advertisement
Guest User

Untitled

a guest
Nov 30th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. <?php
  2.  
  3. $servername = "localhost";
  4. $username = "root";
  5. $password = "";
  6. $db = "artikel";
  7.  
  8. $conn = new mysqli($servername, $username, $password, $db);
  9.  
  10. $search = '';
  11.  
  12. if (array_key_exists('search', $_GET)) {
  13.  
  14. $search = $_GET['search'];
  15. $sql = "SELECT * FROM artikel WHERE * LIKE '%" . $search . "%'";
  16. $result = mysql_query($sql);
  17.  
  18. // var_dump($result);
  19.  
  20. if ($result->num_rows > 0) {
  21. while ($row = mysql_fetch_object($result)) {
  22. echo $row->prijs;
  23. echo $row->artikelnaam;
  24. }
  25. } else {
  26. echo "niets gevonden";
  27. }
  28. }
  29. mysql_free_result($result);
  30. $conn->close();
  31. ?>
  32.  
  33.  
  34. <form method="get" action="">
  35. <input id="search" name="search" type="text" placeholder="search">
  36. <input type="submit" name="submit">
  37. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement