Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. //Zoek form
  2.  
  3. <form method="post" action="search.php">
  4. <select name="metode" size="1">
  5. <option value="naam">naam</option>
  6. <option value="jaar">jaar</option>
  7. <option value="prijs">prijs</option></select>
  8. <input type="text" name="search" size="25">
  9. <input type="submit" value="Zoeken">
  10. </form>
  11.  
  12. //search.php
  13.  
  14. <?
  15. $hostname = "localhost"; // Usually localhost.
  16. $username = "user"; // If you have no username, leave this space empty.
  17. $password = "pass"; // The same applies here.
  18. $dbName = "DBname"; // This is the main database you connect to.
  19. MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect to database");
  20. @mysql_select_db( "$dbName") or die( "Unable to select database");
  21. ?>
  22. <?
  23.  
  24. //error message (not found message)
  25. $XX = "<li>No Record Found</li>";
  26.  
  27. //if ($metode = 'kleur.naam'){
  28. $query = mysql_query("SELECT wijn.id as id, wijn.naam as wijn, wijn.jaar as jaar, wijn.prijs as prijs, kleur.naam as kleur, land.naam as land, streek.naam as streek FROM kleur,wijn,land,streek WHERE $metode LIKE '%$search%' AND kleur.id = wijn.kleur_id AND land.id = wijn.land_id AND land.id = streek.land_id AND streek.id = wijn.streek_id LIMIT 0, 51");
  29. //}
  30. //else{
  31. //$query = mysql_query("SELECT * FROM wijn WHERE $metode LIKE '%$search%' LIMIT 0, 30");
  32. //}
  33. //$result = mysql_query($query) or die(mysql_error());
  34.  
  35. while ($row = mysql_fetch_array($query))
  36. {
  37. $variable=$row["id"];
  38. $variable1=$row["wijn"];
  39. $variable2=$row["jaar"];
  40. $variable3=$row["prijs"];
  41.  
  42. print $variable1</span>";
  43.  
  44.  
  45. }
  46.  
  47. //below this is the function for no record!!
  48. if (!$variable1)
  49. {
  50. print ("$XX");
  51. }
  52. //end
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement