Okay,
I written this code here, but when a horse is selected and submit is clicked the whole page refreshes and runs the query with the first horse in the list.
AND to add to it all, I get this error when I include the "AND rider='$shname' " in the query "$rides"
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /var/www/html/ridetime1.php on line 97
<form method="post" action="<?php $PHP_SELF ?>">
<?php
$hourqry=mysql_query("SELECT * FROM horse");
echo '<td>Horse:<select name=hhours>';
while ($hrow = @mysql_fetch_assoc($hourqry))
{
echo "<option value=\"$hrow[reg_num]\">$hrow[reg_name]</option>\n";
}
echo '</select></td></tr><tr><td>';
echo ("<input type=Submit name=rsubmit value=Show></form>");
if ($rsubmit) {
$shname=$_SESSION['username'];
$rides=mysql_query("SELECT * FROM ridehours WHERE reg_num='$hhours' AND rider='$shname'");
$hournum=mysql_numrows($rides);
$hr=0;
while ($hr < $hournum) {
$date=mysql_result($rides,$hr,"date");
$rider=mysql_result($rides,$hr,"rider");
$ridelocation=mysql_result($rides,$hr,"ridelocation");
$hours=mysql_result($rides,$hr,"hours");
echo ("$date<br>$rider | $ridelocation | $hours<br>");
++$hr;
}
} else {
echo ("Please select a horse to view hours you've ridden.");
}
?>