First and foremost, I'm an idiot... as all of you will see. Building in DW.
Form to submit report title
<form id="form1" name="form1" method="post" action="assign_report.php">
<p>Create report </p>
<p>
<input name="title" type="text" id="title" />
</p>
<p>
<input type="submit" name="Submit" value="Submit" />
</p>
</form>
Submits to this
<?php
mysql_select_db($database_ngiportalDB_report_tool, $ngiportalDB_report_tool);
$query_users = "SELECT realName, emailAddress FROM int_members";
$users = mysql_query($query_users, $ngiportalDB_report_tool) or die(mysql_error());
$row_users = mysql_fetch_assoc($users);
$totalRows_users = mysql_num_rows($users);
?>
<body>
<form id="form1" name="form1" method="post" action="upload_report.php">
<table >
<tr>
<?php
$users_endRow = 0;
$users_columns = 4; // number of columns
$users_hloopRow1 = 0; // first row flag
do {
if($users_endRow == 0 && $users_hloopRow1++ != 0) echo "<tr>";
?>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<input name="title" type="hidden" value="<?php echo $_POST['title'];?>" />
<input name="user" type="checkbox" id="user[]" value="<?php echo $row_users['realName']; ?>" /><?php echo $row_users['realName']; ?>
<input name="email" type="hidden" value="<?php echo $row_users['emailAddress']; ?>" /></td>
</tr>
</table></td>
<?php $users_endRow++;
if($users_endRow >= $users_columns) {
?>
</tr>
<?php
$users_endRow = 0;
}
} while ($row_users = mysql_fetch_assoc($users));
if($users_endRow != 0) {
while ($users_endRow < $users_columns) {
echo("<td> </td>");
$users_endRow++;
}
echo("</tr>");
}?>
</table><p>
<input type="submit" name="Submit" value="Submit" />
</p>
</form>
</body>
</html>
<?php
mysql_free_result($users);
?>
And I try to show the results with this, as well as update the database
<?php require_once('Connections/ngiportalDB_report_tool.php'); ?>
<?php
if(isset($_POST['user'][$key]))
{
$title = $_POST['title'];
$user = $_POST['user'];
$email = $_POST['email'];
$n = count($user);
$i = 0;
echo "The title you created was \r\n";
while ($i < $n)
{
$result=MYSQL_QUERY("INSERT INTO custom_reports (title[$i], user[$i], email[$i]) ". "VALUES ('$title','$user','$email')");
$id= mysql_insert_id();
print "<br>Report Title: <b>$title</b><br>";
print "User Name: <b>$user</b><br>";
print "User Email: <b>$email</b><br>";
$i++;
}
}
?>
It will show the report TITLE, the LAST user name I selected, and the LAST email address (hidden field from 2nd page) even if it is NOT selected. It always pulls the LAST email field from the form, no matter what.
My dilemma...
How do I pass the array values for ALL the selected checkboxes and have them pass the information correctly? I can't make it pass one line like TITLE, USER1, EMAIL1... TITLE, USER2, EMAIL2... etc. I have downloaded code from 20 different articles here and tried making my program work. I hope it is a simple array variable I botched or something in the while statement that has to be fixed, but I can't find it.