View Full Version : php checkboxes forms

11-03-2006, 07:18 PM

I have a page which reads records from MySQL database into an html written form. Besdie each record there is a checkbox. Ideally I would like for a user to check the checkbox beside a record, click submit, and the on the next page display the record again so it can be updated.

However, I am not sure what hitting submit actually takes from the first page to the next. The code I have is below:


mysql_connect("localhost", "root", "dinosaur") or die(mysql_error());
mysql_select_db("info") or die(mysql_error());

$query = "SELECT fname, sname, teamname, username, priv FROM users"; $result = mysql_query($query) or die(mysql_error());

echo "<form name=myForm action='Edit.php' method='post'><table border=1 class='table'><tr><td>First Name</td><td>Second Name</td><td>Team Name</td><td>Username</td><td>Privilege</td><td>Edit</td></tr>";

while($row = mysql_fetch_array($result)){

echo "<tr><td>" . $row['fname']. "</td><td>" . $row['sname'] . "</td><td>" . $row['teamname'] . "</td><td>" .
$row['username'] . "</td><td>" . $row['priv'] . "</td><td><input type='checkbox' name='" .
$row['userID'] . "></td></tr>";

echo "<tr><td colspan=3 align=center><input type='submit' value='Confirm'></form></td><td colspan=3 align=center></td</tr></table>";

Each checkbox should be named with the unique number of the record each time the next one is displayed. From here how would i display the corresponding record on another page?? How does the next page know which checkbox has been checked? what is taken across to this next page ?? I dont understand !!!!!!!