Experts,
I have created a table that places information from the db in each column. In the loop that creates the table I have also added a checkbox that appears in the last column of each row. I need to create a form processor that will allow the user to check each box that they would like to show up on another page.
For example, if they click on a check box next to report one, it will show up on page 1. If they unclick the box, then it will not appear on page 1. In addition, I need the boxes to remain checked if the value in the database is equal to Yes. If the value is No, then the box should remain unchecked. The default value in the database is No.
I have included my code which creates the table below. Can anyone offer any starting points?
// CALL ALL REPORTS FROM THE DB AND ORDER THEM BY 'Name'
$sql2="SELECT * FROM controller_reports ORDER BY Name";
$data = mysql_query($sql2) or die ("Could not run query: " . $sql2 . "<br />\n" . mysql_error () );
// IF 'cmd' HAS NOT BEEN INITIALIZED, SHOW THE LIST OF CONTROLLERS IN MEMORY
if(!isset($_GET['cmd']))
{
// 'cmd' HAS NOT BEEN INITIALIZED THERFORE SHOW THE LIST OF CONTROLLERS
echo "Please select the report you would like to edit or delete.
Check the box next to each report you would like to appear on the 'Current' reports page.";
echo "</br></br>";
echo "<b>Note:</b> You can sort any column by clicking on the column's title.";
echo "</br></br>";
echo "PPR = Pay Period Report";
echo "<div align='center'>";
echo "<form name='form' method='post' action='
http://diablo.ca.kp.org/dept/controller/show_process.php'>
";
echo '<table id="myTable" width="100%" border="0" cellspacing="3" cellpadding="3" style="font-size:10px;">';
echo '<thead>';
echo '<tr><td colspan="8" align="right">
<input name="submit" type="submit" value="go" style="margin-right:5px;" />
</td></tr>';
echo '<tr>';
echo '<th><b><u>Report Name</u></b></th>';
echo '<th><b><u>Year</u></b></t
h>';
echo '<th><b><u>Month</u></b></
th>';
echo '<th><b><u>Date</u></b></t
h>';
echo '<th><b><u>PPR</u></b></th
>';
echo '<th><b><u>PPR Desc.</u></b></th>';
echo '<th><b><u>Action</u></b><
/th>';
echo '<th><b><u>Show</u></b></t
h>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
// THIS SETS UP THE COLOR STYLE FOR EACH ROW, INSIDE THE WHILE LOOP WE WILL ASK THE COLORS TO ALTERNATE
$style = 0;
// THIS WHILE LOOP CREATES ROW AFTER ROW OF CONTROLLER UNTIL THERE ARE NO MORE CONTROLLERS TO LIST
while ($getinfo2 = mysql_fetch_assoc($data)){
//inside the loop change the class of the row/column
//(based on a style sheet). you could also directly specify
//a background colour here
if($style == 1) {
$tclass = "row1";
$style = 0;
} else {
$tclass = "row2";
$style = 1;
}
// GRAB THE UNIQUE 'id' OF EACH USER
$id=$getinfo2["id"];//take
out the id
echo '
<tr class="'.$tclass.'" style="padding-top:4px; padding-bottom:4px;">
<td>'.$getinfo2['Name'].'<
/td>
<td>'.$getinfo2['Year'].'<
/td>
<td>'.$getinfo2['Month'].'
</td>
<td>'.$getinfo2['Date'].'<
/td>
<td>'.$getinfo2['PayPeriod
'].'</td>
<td>'.$getinfo2['Ending'].
'</td>
<td>
<a href="
http://diablo.ca.kp.org/dept/controller/edit_report.php?cmd=edit&id='.$getinfo2['id'].'"
title="Edit '.$getinfo2['Name'].' of: '.$getinfo2['Date'].'">Edi
t</a> -
<a href="
http://diablo.ca.kp.org/dept/controller/edit_report.php?cmd=delete&id='.$getinfo2['id'].'"
';
// THIS ONCLICK EVENT GIVES YOU THE POP UP MESSAGE TO CONFIRM THAT YOU WANT TO DELETE THIS ACCOUNT
echo'
onclick="return confirm("Are you sure you would like to\nDELETE '.$getinfo2['Name'].' of: '.$getinfo2['Date'].'\n\nP
lease click \'OK\' to delete or \'CANCEL\' to go back.")"
title="Delete '.$getinfo2['Name'].' of: '.$getinfo2['Date'].'">Del
ete</a>
</td>
<td><input name="Show" type="checkbox" value="Yes" title="Checked = Yes | Unchecked = No" /></td>
</tr>';
}// END WHILE LOOP
// CLOSE THE TABLE
echo '</tbody>';
echo '<tr><td colspan="8" align="right">
<input name="submit" type="submit" value="go" style="margin-right:5px;" />
</td></tr>';
echo '</table>';
echo '</form>';
echo "</div>";
}