I have a form that get's pre populated from an events_result table. It has fname,lastname,event,results column. I have a link to Update which is an action call to function UpdateResults. I want to be able to use this one form to show the results and be able to update the results column if needed. Below is the code. I did have the UpdateResults in a separate functions.php file but that really wasn't working. Right now my update command give's me everything i want but the new/edited results value. its not getting passed correctly some how.
// Make the query:
$query = "SELECT * FROM athlete,events,event_results where athlete.athlete_id = event_results.athlete_id
and events.event = event_results.event ORDER BY $order_by LIMIT $start, $display";
$res = mysql_query($query);
echo '<form name="form1" action="mathleteresults.php" method="post">';
// Table header:
echo '<table align="center" cellspacing="0" cellpadding="5" width="155%">
<tr>
<td align="left"><b>Edit</b></td>
<td align="left"><b>Delete</b></td>
<td align="left"><b>FirstName</b></td>
<td align="left"><b>LastName</b></td>
<td align="left"><b><a href="mathleteresults.php?sort=eventorder">Event</a></b></td>
<td align="left"><b><a href="mathleteresults.php?sort=result">Results</a></b></td>
<td align="left"><b>Date</b></td>
</tr>';
// Fetch and print all the records....
$bg = '#eeeeee';
while ($row = sqlFetchArray($res)) {
$bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee');
//echo $a_id;
echo '<tr bgcolor="' . $bg . '">
<td align="left"><a href="?action=UpdateResult&athlete_id=' . $row['athlete_id'] . '&event=' .$row['event'] . '&result=' . $row['result'] .'" >Update </a></td>
<td align="left"><a href="?action=DeleteResult&athlete_id=' . $row['athlete_id'] . '">Delete</a></td>
<td align="left">' . $row['first_name'] . '</td>
<td align="left">' . $row['last_name'] . '</td>
<td align="left"><input name="event" size="10" id="event" value="' . $row['event'] . '"></td>
<td align="left"><input type="text" name="result" id="result" size="8" value="' . $row['result'] . '" ></td>
<td align="left">' . $row['date'] . '</td>
</tr>';
} // End of WHILE loop.
echo '</table>';
echo '</form>';
//request to edit/update result
if ((isset($_GET['action']))&&($_GET['action']=='UpdateResult'))
{ echo "just cant find the result";
$time = $_GET["result"];
$event = $_GET['event'];
$id = $_GET['athlete_id'];
$sql = "UPDATE event_results set result='".$time."' Where event='$event' and athlete_id='$id'";
echo $sql;
$res = sqlQuery($sql); if(sqlErrorReturn()) sqlDebug(__FILE__,__LINE__,sqlErrorReturn());
if (!empty($res))
return 99;
return false;
}
This is a pic of the form.