Hi there, i have what probably is a very basic question ....
I have a drop down menu and it is populated from a SELECT statement and the user clicks on Submit .... i want to use the option that the user picks to run another SELECT and show the results on another page !!
How can i run the query based on that ..... i dont know how to carry out the select and format it into columns etc. and send this all to another page. I want to use the other page for loads of different types of searches ... all with very different results.
Here is my code so far .....
<html>
<body>
<?php
$username = "username";
$password = "password";
$hostname = "IP address or localhost";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
print "Connected to MySQL<br>";
$selected = mysql_select_db("databasename",$dbh)
or die("Could not select my database");
print "Connected to database<br>";
function generate_box() {
$sql = "SELECT ClubNo, ClubName FROM club";
$result = mysql_query($sql) or die(mysql_error());
$entries = mysql_num_rows($result);
$options = '<option value="-1"></option>';
while($row = mysql_fetch_assoc($result)) {
$options .= "<option value=\"{$row['ClubNo']}\">{$row['ClubName']}</option>";
}
return $options;
}
$options = generate_box();
?>
<table>
<form method="get" name="forum_select" action="search.php"><table cellspacing="0" cellpadding="0" border="0">
<tr>
<td><span>Search By:
<select name="by">
<? echo "$options"; ?>
<input type="submit" value="Submit"></span></td>
</tr>
</table></form>
</body>
</html>