I really need someone to help me on the scenario below.
I fetch all the rows in a database table with the mysql_fetch_array() and it was successful. I placed a button on each row in order to click and take the user to another page. On click of the button, i want session to take the values of all columns on that particular row to the other page.
But i discovered that on click on any of the button, session only registered the last row of the table not minding maybe i click on the button of the first row or any other row. I need someone to put me through on this and i will really appreciate all suggestions.
Thanks in advance.
below is a copy of my script for your understanding.
$select = "select * from platform";
$result = mysql_query($select) or die(mysql_error());
echo "<table border = '1' bordercolor = '#CC6600' cellspacing = '0'>";
echo "<tr><th>Category</th><th>Code</th><th>Game</th><th>Valid Time</th></tr>";
while($row = mysql_fetch_array($result)){
echo '<form name = "form2" method = "post" action = "predictproc.php">';
echo "<tr><td width = '100'>";
echo $row['category'];
echo "</td><td width = '100'>";
echo $row['competitioncode'];
echo "</td><td width = '250'>";
echo $row['teama']; echo ' '; echo "vs"; echo ' '; echo $row['teamb'];
echo "</td><td width = '100'>";
echo $row['kickoff'];
echo "</td><td>";
echo '<input type = "Submit" name = "Submit" value = "Play This" class = "button">';
echo "</td></tr>";
$gamecode = $row['competitioncode'];
echo '</form>';
//my problem starts here, I want session variables to be created for each row if I click on the button of that particular row. but no matter what button i click, it retrieves record of only the last row on the other page.
$predict = "select * from platform where competitioncode = '$gamecode'";
$predict_result = mysql_query($predict) or die("can't select for predict");
if($predict_result)
{
if(mysql_num_rows($predict_result) == 1)
{
$predictrow = mysql_fetch_array($predict_result);
$_SESSION['category'] = $predictrow['category'];
$_SESSION['competitioncode'] = $predictrow['competitioncode'];
$_SESSION['teama'] = $predictrow['teama'];
$_SESSION['teamb'] = $predictrow['teamb'];
$_SESSION['kickoff'] = $predictrow['kickoff'];
}
}
}
echo "</table>";
?>