Hi, I'm looking to filter out my results from a MySQL database table using a drop-down menu. Here is my code:
"shows.html"
<form method="post" action="shows.php">
<label>
<select name="bandselection" id="bandselection">
<option value="BandA" selected="selected">BandA</option>
<option value="BandB">BandB</option>
<option value="BandC">BandC</option>
<option value="BandD">BandD</option>
</select>
</label>
<label>
<input type="submit" name="Submit" value="Submit" />
</label>
</form>
"shows.php"
<?
$host="***";
$username="***";
$password="***";
$database="***";
$bandselection = $_POST['bandselection'];
mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM shows WHERE `date` >= CURDATE() ORDER by `date` ASC WHERE `band` = '" . $bandselection ."'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
$date=mysql_result($result,$i,"date");
$band=mysql_result($result,$i,"band");
$venue=mysql_result($result,$i,"venue");
$time=mysql_result($result,$i,"time");
$band1=mysql_result($result,$i,"band1");
$band2=mysql_result($result,$i,"band2");
$band3=mysql_result($result,$i,"band3");
echo "<b><font size=2>$date: $band</font></b><font size=1> @ $venue, $time<br>w/ $band1, $band2<br></font><br>";
$i++;
}
?>
I get the error message: "
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /***/shows.php on line 11"
Can anyone help me to see what's wrong?