Ok I am currently learning php through wordpress and I have a small project to create a running website which displays the results.
CUrrently I can display the results for a certain race that I hard code:
<?php // Connects to your Database
mysql_connect("XX.XX.XX.XX", "admin", "pwd") or die(mysql_error());
mysql_select_db("db") or die(mysql_error());
$query = mysql_query("
SELECT R.FirstName, R.LastName, R.Category, C.ClubName,
RR.Position, RR.Time, RR.PercentageOfLeader
FROM runner R
INNER JOIN PersonClub PC ON PC.RaceNumber = R.RaceNumber
INNER JOIN Club C ON PC.ClubID = C.ID
INNER JOIN RaceRunner RR ON RR.RaceNumber = R.RaceNumber
INNER JOIN Race RRR ON RRR.RaceID = RR.RaceID
WHERE RRR.RaceID = 2
ORDER BY RR.Position
") or die(mysql_error());
$num=mysql_numrows($query);
echo "<table border='1'>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Category</th>
<th>Club</th>
<th>Position</th>
<th>Time</th>
<th>% behind Leader</th>
</tr>";
while($row = mysql_fetch_array($query) or die(mysql_error()))
{
echo "<tr>";
echo "<td>" . $row['FirstName'] . "</td>";
echo "<td>" . $row['LastName'] . "</td>";
echo "<td>" . $row['Category'] . "</td>";
echo "<td>" . $row['ClubName'] . "</td>";
echo "<td>" . $row['Position'] . "</td>";
echo "<td>" . $row['Time'] . "</td>";
echo "<td>" . $row['PercentageOfLeader'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close();
?>
Now I am happy with this but that means I need to create different pages for different races but what I really want it to have a drop down box which contains the races and when a user chooses a race (onEvent) then I pass the RaceID to the sql query and display the results in the same page. They then can change the dropdown to another race and it will repopulate with the next race results.
I am assuming I will need a php function which will need to be called with a onEvent call. Any help is much appreciated as I am doing this in wordpress with exec-php plugin.
Thanks