Check Box hell PHP
Posted: Sun Jan 27, 2008 11:43 am
Hi, trying to load items from MySQL and then display them in a table with a check box to select the $pupil_id so i can either
multiple delete or go to a screen to view the displayed row.
So, far got the table printed out with the mysql data but cannot get the check box values to pass over to the next screen when i POST. Pretty sure its just the syntax regarding the checkbox part inside the $display_block
here's the code and a pic to show how the table and checkbox are done
$display_block .= "<table width='740' border='5' cellspacing='2'>";
$display_block .= "<form name='myform' action='post_check.php' method='POST'>";
while($row=mysql_fetch_array($results))
{
$pupil_id =$row['pupil_id'];
$pupil_first_name =$row['pupil_first_name'];
$pupil_last_name =$row['pupil_last_name'];
$pupil_gender =$row['pupil_gender'];
$pupil_year_group=$row['pupil_year_group'];
$display_block .="<tr><td width='50'>
<input type=checkbox name='box[]' value='$pupil_id'></td>
<td width='100'>$pupil_id</td>
<td width='100'>$pupil_gender</td>
<td width='200'>$pupil_last_name</td>
<td width='200'>$pupil_first_name</td>
<td width='100'>$pupil_year_group</td></tr>";
}
echo $display_block;
echo "<input type='submit' value='Submit' name='testform'>";
echo "</form";
echo "</table";
?>
multiple delete or go to a screen to view the displayed row.
So, far got the table printed out with the mysql data but cannot get the check box values to pass over to the next screen when i POST. Pretty sure its just the syntax regarding the checkbox part inside the $display_block
here's the code and a pic to show how the table and checkbox are done
$display_block .= "<table width='740' border='5' cellspacing='2'>";
$display_block .= "<form name='myform' action='post_check.php' method='POST'>";
while($row=mysql_fetch_array($results))
{
$pupil_id =$row['pupil_id'];
$pupil_first_name =$row['pupil_first_name'];
$pupil_last_name =$row['pupil_last_name'];
$pupil_gender =$row['pupil_gender'];
$pupil_year_group=$row['pupil_year_group'];
$display_block .="<tr><td width='50'>
<input type=checkbox name='box[]' value='$pupil_id'></td>
<td width='100'>$pupil_id</td>
<td width='100'>$pupil_gender</td>
<td width='200'>$pupil_last_name</td>
<td width='200'>$pupil_first_name</td>
<td width='100'>$pupil_year_group</td></tr>";
}
echo $display_block;
echo "<input type='submit' value='Submit' name='testform'>";
echo "</form";
echo "</table";
?>