I have a form in which there is a table that displays a list from the MySQL with checkboxes to each displayed name. I have to make a selection out from the list by checking some the checkboxes all may be all the checkboxes in some circumstances.
A. I have to validate the selection made
B. I have to store the value of the selected checkboxes into an array
I need assistance as I do not know how and what to validate against for the checkboxes.
// Make a MySQL Connection
$conn = mysql_connect("", "", "")
or die(mysql_error());
mysql_select_db("",$conn) or die(mysql_error());
$my_list = "select emp_no, concat_ws(', ', lname, fname) as display_name
from employee order by lname, fname";
$my_list_res = mysql_query($my_list) or die(mysql_error());
if (mysql_num_rows($my_list_res) < 1) {
//no records
echo "<p><em>Sorry, no records to select!</em></p>";
} else {
// array that accepts the employee list - shd use $_SESSION???
$hello_array[] = $my_list_res;
?>
<!-- major table starts here -->
<center>
<form name="slip" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<?php
echo "<table border='1'>";
echo "<tr> <th>Last Name, First Name</th> <th>Check / UnCheck </th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $get_list_res )) {
// Print out the contents of each row into a table
echo "<tr><td>";
//echo $row['name'];
echo $display_name = stripslashes($row['display_name']);
echo "</td><td>";
echo "<input type=\"checkbox\" name=\"dname[]\" value=\"row['emp_no']\">";
echo "</td> </tr>";
}
}
echo "</table>";
?>
</center>
<!-- Cancel and Next Buttons should be placed in a form -->
<br />
<br />
<center>
<input type="Submit" name="cancel" value="CANCEL!!!" action="my_meeting.php">
<input type="submit" name="nex" value="Next">
</form></center>
<?php
if(isset($_POST['nex'])){
/**
* ensure all the selected checkboxes pass their ids to a new array
*
*/
header('location:auntie.php');
echo "<br />";
exit();
}else if (isset ($_POST['cancel'])){
// return to uncle.php
header('location:uncle.php');
echo "<br />";
exit();
}
?>