Advertisement
Guest User

Untitled

a guest
Oct 14th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4. <?php
  5. $servername = "localhost";
  6. $username = "myusername";
  7. $password = "mypassword";
  8. $dbname = "mydatabase";
  9. // Create connection
  10. $conn = new mysqli($servername, $username, $password, $dbname);
  11. // Check connection
  12. if ($conn->connect_error) {
  13. die("Connection failed: " . $conn->connect_error);
  14. }
  15. if(!isset($_POST['country_type']) ||
  16. !isset($_POST['region_type']) ||
  17. !isset($_POST['wine_type']) ||
  18. !isset($_POST['vintage_type'])) {
  19. died('<p>We are sorry, but there appears to be a problem with the form you submitted.</p>');
  20. }
  21. $country_type = $_POST['country_type'];
  22. $region_type = $_POST['region_type'];
  23. $wine_type = $_POST['wine_type'];
  24. $vintage_type = $_POST['vintage_type'];
  25. $sql = "* FROM wp_winenotes
  26. WHERE Country = $country_type
  27. AND Wine = $wine_type
  28. AND Region = $region_type
  29. AND Vintage = $vintage_type;
  30. $result = $conn->query($sql);
  31. if ($result->num_rows > 0) {
  32. // output data of each selected row
  33. while($row = $result->fetch_assoc()) {
  34. $wine = iconv('ASCII', 'UTF-8//IGNORE', $row['Wine']);
  35. $note = iconv('ASCII', 'UTF-8//IGNORE', $row['Note']);
  36. echo "<br> id: ". $row['id']. " - Wine: " . $wine . "<br>Note: " . $note . "<br>";
  37. }
  38. } else {
  39. echo "0 results";
  40. }
  41. $conn->close();
  42. ?>
  43. </body>
  44. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement