This is a project for a fantasy nascar league I'm running.
I've got a page that lists 45 nascar drivers. It lists their CarNumber, DriverName, Points, Group. As you can see in the code, the Points column is a field that the user can change. Each week, I will change the points to reflect the official points standing.
The first page works fine. However, my update code is wrong because when I submit the form, it updates all the drivers with the same number of points that was input for the 45th record. I think some sort of loop is needed in the processpoints.php code but I am not sure how this is done 🙂
The code below is my form and the part I'm having trouble is with the <form action = processpoints.php .... which is also below.
$connection = mysql_connect($dbhost, $dbuser, $dbpass)
or die ("Not Able to connect");
$db = mysql_select_db($dbname, $connection)
or die ("Not Able to connect");
echo "<br>Update the Points For Each Driver - Then Hit Submit</br><hr>";
$query = "SELECT * FROM DriversORDER BY Points DESC";
$result = mysql_query($query)
or die ("Not Able to connect");
while ($row = mysql_fetch_array($result))
{
echo "<table cellspacing=0 border=0>\n";
extract($row);
echo "<form action='processpoints.php' method='post'>
<tr>\n
<td width=55>$CarNumber</td>\n
<td width=100>$DriverName</td>\n
<td><input type='text' name='Points' size = '6' maxlength='11' value='$Points'> </td>\n
<td width=55>$Group</td>\n
</tr>";
}
echo "</table>\n";
echo "<p align='left'><input type= 'submit' value='Submit Points Change'</p>
</form>";
?>
Here is the processpoints.php code (i know it's not correct. This is the part I need help on)
<?php
$dbhost =
$dbuser =
$dbpass =
$dbname = "nascar";
$connection = mysql_connect($dbhost, $dbuser, $dbpass)
or die ("Not Able to connect");
$db = mysql_select_db($dbname, $connection)
or die ("Not Able to connect");
$query = "UPDATE Drivers SET Points=$Points";
$result = mysql_query($query)
or die ("Not Able to connect");
?>