Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $dbhost = 'localhost';
- $dbuser = 'root';
- $dbpass = 'root';
- $link = mysql_connect($dbhost,$dbuser,$dbpass);
- mysql_select_db("demo",$link);
- //User submits the form
- if(isset($_POST['Submit']))
- {
- $selectItem1 = $_POST['selectItem1'];
- $selectItem2 = $_POST['selectItem2'];
- }
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
- <html>
- <head>
- <title>Chart This!</title>
- </head>
- <body>
- <form method="post" action="result.php">
- <table width=300 align=center>
- <tr>
- <td>Choose Dates:</td>
- <td>
- <?php
- $query = "select Date from permdata";
- $results = mysql_query($query, $link) or die("Error performing query");
- if(mysql_num_rows($results) > 0)
- {
- echo("<select name=\"selectItem1\">");
- while($row1 = mysql_fetch_object($results))
- {
- echo("<option value=\"$row1->Date\">$row1->Date</option>");
- }
- echo("</select>");
- } else {
- echo("<i>No values found</i>");
- }
- if(mysql_num_rows($results) > 0)
- {
- echo("<select name=\"selectItem2\">");
- while($row2 = mysql_fetch_object($results))
- {
- echo("<option value=\"$row2->Date\">$row2->Date</option>");
- }
- echo("</select>");
- } else {
- echo("<i>No values found</i>");
- }
- ?>
- </td>
- </tr>
- <tr>
- <td><input type=submit></td>
- </tr>
- </table>
- </form>
- </body>
- </html>
Add Comment
Please, Sign In to add comment