C
critical
Guest
Im trying to print the values of the checked boxes of a php dynamically generated check box on my page, but cannot get hold of those values, the variable dump comes out null. My codes are the followings:
<form action="<?=$_SERVER['PHP_SELF']?>" method="post" name="check">
<?php
echo "<table border='0'>
<tr>
<td colspan='3'>Please choose no more than six.</td>
</tr>
<tr>
<th>No.</th>
<th colspan='2'>Module Code</th>
<th>Title</th>
</tr>";
$count = 0;
while($row = mysql_fetch_array($result))
{
$count = $count+1;
// output a form with checkbox and values of the module row
echo "<tr>";
echo "<td>" .$count."</td>";
echo '<td><input type="checkbox" name="modules[]" value="'. $row['ModuleID'].'" onClick=check_Restrict(this) unchecked/></td>';
echo "<td>" . $row['ModuleID'] . "</td>";
echo "<td>" . $row['Title'] . "</td>";
echo "</tr>";
}
?>
<tr>
<td colspan='2'><input type="submit" name="submit" value="Submit" />
<input name="hidSubmit" type="hidden" id="hidSubmit2" value="true"></td>
</td>
<td><input type="reset" value="Reset!"></td>
</tr>
</form>
<?php
if (isset($_POST['submit'])) {
if (isset($_POST['modules'])) {
$modules = $_POST['modules'];
if ($modules == $row['ModuleID'])
{
echo $modules;
$modules = 'checked';
}
}
}
var_dump($modules);
// mysql_close($con);
?>
thaks in advance for any help.
<form action="<?=$_SERVER['PHP_SELF']?>" method="post" name="check">
<?php
echo "<table border='0'>
<tr>
<td colspan='3'>Please choose no more than six.</td>
</tr>
<tr>
<th>No.</th>
<th colspan='2'>Module Code</th>
<th>Title</th>
</tr>";
$count = 0;
while($row = mysql_fetch_array($result))
{
$count = $count+1;
// output a form with checkbox and values of the module row
echo "<tr>";
echo "<td>" .$count."</td>";
echo '<td><input type="checkbox" name="modules[]" value="'. $row['ModuleID'].'" onClick=check_Restrict(this) unchecked/></td>';
echo "<td>" . $row['ModuleID'] . "</td>";
echo "<td>" . $row['Title'] . "</td>";
echo "</tr>";
}
?>
<tr>
<td colspan='2'><input type="submit" name="submit" value="Submit" />
<input name="hidSubmit" type="hidden" id="hidSubmit2" value="true"></td>
</td>
<td><input type="reset" value="Reset!"></td>
</tr>
</form>
<?php
if (isset($_POST['submit'])) {
if (isset($_POST['modules'])) {
$modules = $_POST['modules'];
if ($modules == $row['ModuleID'])
{
echo $modules;
$modules = 'checked';
}
}
}
var_dump($modules);
// mysql_close($con);
?>
thaks in advance for any help.