Guest User

Untitled

a guest
Jun 8th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. <?php
  2. $dbhost = 'localhost';
  3. $dbuser = 'root';
  4. $dbpass = 'root';
  5.  
  6. $link = mysql_connect($dbhost,$dbuser,$dbpass);
  7. mysql_select_db("demo",$link);
  8.  
  9. //User submits the form
  10. if(isset($_POST['Submit']))
  11. {
  12. $selectItem1 = $_POST['selectItem1'];
  13. $selectItem2 = $_POST['selectItem2'];
  14. }
  15. ?>
  16. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
  17. <html>
  18. <head>
  19. <title>Chart This!</title>
  20. </head>
  21. <body>
  22. <form method="post" action="result.php">
  23. <table width=300 align=center>
  24. <tr>
  25. <td>Choose Dates:</td>
  26. <td>
  27. <?php
  28.  
  29. $query = "select Date from permdata";
  30. $results = mysql_query($query, $link) or die("Error performing query");
  31.  
  32. if(mysql_num_rows($results) > 0)
  33. {
  34. echo("<select name=\"selectItem1\">");
  35. while($row1 = mysql_fetch_object($results))
  36. {
  37. echo("<option value=\"$row1->Date\">$row1->Date</option>");
  38. }
  39. echo("</select>");
  40. } else {
  41. echo("<i>No values found</i>");
  42. }
  43.  
  44. if(mysql_num_rows($results) > 0)
  45. {
  46. echo("<select name=\"selectItem2\">");
  47. while($row2 = mysql_fetch_object($results))
  48. {
  49. echo("<option value=\"$row2->Date\">$row2->Date</option>");
  50. }
  51. echo("</select>");
  52. } else {
  53. echo("<i>No values found</i>");
  54. }
  55. ?>
  56. </td>
  57. </tr>
  58. <tr>
  59. <td><input type=submit></td>
  60. </tr>
  61. </table>
  62. </form>
  63. </body>
  64. </html>
Add Comment
Please, Sign In to add comment