Hello all, I am trying to build a query that a user can do by selecting something in a drop-down box. I am getting a "line 1" syntax error though on the return results code. Can someone check out the code for obvious errors please and reply with any ideas on how to write if correctly?
Here is the code for the select form with the drop-down box that seems to work fine.
PHP Code:
<form action="driverraceresults.php" method="post">
<table cellpadding="0" cellspacing="5" border="0" width="450">
<tr><td class="scheduleheader">View a driver's Race Results</td></tr>
<tr><td>
<?php
$sql = "SELECT Driver FROM season04 ORDER by Driver ASC";
$results = mysql_query($sql);
print("<select width=\"150\" style=\"width: 150px\" name=\"select\">\n" );
while ($row = mysql_fetch_array($results)):
$name = $row["Driver"];
print("<option value=\"$name\">$name\n" );
endwhile;
print("</select>\n" );
?>
</td><tr>
<td align="center"><br /><input class="lefttext" type="submit" name="submit" value="Submit"></td>
</tr>
</table>
</form>
Here is the code for the return results page as listed in the "action" for the form up above:
PHP Code:
print"<table class=\"userstats\" border=\"1\" style=\"width:85%;\">
<tr class=\"scheduleheader\"><td>Finish</td><td>Start</td><td>Car#</td><td>Driver</td><td>Interval</td><td>Laps</td><td>Led</td>
<td>Pts</td><td>Status</td></tr>";
$query=" SELECT * FROM nc04, lv04, atl04 WHERE Driver = " .$_REQUEST['select'];
$result=mysql_query($query);
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>" );
exit();
}
if ($row = @mysql_fetch_array($result, MYSQL_ASSOC)) {
print"<tr class=\"scheduledata\"><td>$row[Finish]</td><td>$row[Start]</td><td>$row[Car_Number]</td><td>$row[Driver]</td>
<td>$row[Interval_Difference]</td><td>$row[Laps]</td><td>$row[Led]</td><td>$row[Points]</td><td>$row[Status_End]</td></tr>";
}
print"</table>";
?>
I am new to this type of function so please be gentle, lol
Thank you, Troy
Bookmarks