<?php
if(!isset($_SESSION['FactLimit'])) {
$_SESSION['FactLimit'] = 0;
}
echo "<table border='1'>";
echo "<tr> <th>Name</th> <th>Cost</th> <th>Description</th> <th>Purchase </th> </tr>";
$result = mysql_query("SELECT * FROM `factories` LIMIT ".$_SESSION['FactLimit'].", 10 ") or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
//Print out the contents of each row into a table
echo "<tr><td>";
echo $row['name'];
echo "</td><td>";
echo $row['cost'];
echo "</td><td>";
echo $row['description'];
echo "</td><td>";
echo "<form action=\"purchasefactory.php\" method=\"post\"> ";
echo "<input type=\"hidden\" name=\"factoryid\" value=\"".$row['factoryid']."\"> ";
echo "<input type=\"submit\" name=\"submit\" value=\"Purchase\">";
echo "</td></tr>";
}
no matter how many rows it displays, nor which submit button you hit the next page displays $_POST['factoryid'] as the last row displayed's factoryid and not the row clickeds factoryid