Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.25 KB | None | 0 0
  1. <html>
  2. <head><title>Drop-down test</title></head>
  3. <body>
  4. <!--Makes it so the drop down items are queried from the database><-->
  5. <?php
  6. error_reporting(0);
  7. include ('db_login.php');
  8. $connection = mysql_connect($db_host,$db_username,$db_password);
  9. if (!$connection) die ('Error1!'.mysql_error());
  10. $db_select = mysql_select_db($db_database);
  11. if (!$db_select) die ('Error2!'.mysql_error());
  12. $query = "SELECT column_1 from first_table";
  13. $result = mysql_query($query);
  14. if (!$result) die ('Error3!'.mysql_error());
  15.  
  16. echo ('
  17. <form action="'.$_SERVER['PHP_SELF'].'" method="GET">
  18. <select name="search">
  19. ');
  20. while ($result_row = mysql_fetch_row($result)) {
  21. echo ('
  22. <option>'.$result_row[0].'</option>
  23. ');
  24. }
  25. echo ('
  26. </select>
  27. <input type="submit" value="Go!">'.
  28. '</form>
  29. ');
  30. ?>
  31. <p>
  32. <?php
  33. function returnletters($value1) {
  34. if ($value1 != NULL) {
  35. $query2 = "SELECT column_2 from first_table WHERE column_1 = $value1";
  36. $results = mysql_query($query2);
  37. if (!$results) die ('Error4!'.mysql_error());
  38. while ($result_row = mysql_fetch_row($results)){
  39.     echo ('
  40.     The corresponding letters to this are: <strong>'.$result_row[0].'</strong><br>
  41.     ');
  42.     }
  43. }
  44. else die ('Error5!');
  45. }
  46. ?>
  47.  
  48. <?php
  49. $value = $_GET['search'];
  50. returnletters($value);
  51. ?>
  52. </body>
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement