using checkbox yo update MySql table
Posted
by
Martin
on Stack Overflow
See other posts from Stack Overflow
or by Martin
Published on 2011-01-04T10:33:19Z
Indexed on
2011/01/04
10:54 UTC
Read the original article
Hit count: 410
Hi All
I have been searching round the internet for days on this matter but I keep coming up against a brick wall.
What I have is a table full of checkboxes inside an admin area acting as a monthly "to-do" list. It's essentially a worksheet of 30 or so things to do each month that must be checked off each month and notes added if applicable.
I have managed to get the checkboxes to update via mysql and be shown somewhere as a list of ticks. I simply did this my setting the value to 1 and on submission it updates the sql table.
I have to cover my bases here and also offer the option to un-tick items if they have been ticked b y mistake. But I cant figure out how this is done.
Below is my checking code... any help on this matter would be great.
<?php
$currentTask = '';
echo "<tr class='tr'>";
while ($seolistRow = mysql_fetch_array($seolistRes)) {
$taskValue = $seolistRow["taskValue"];
$worksheetID = $seolistRow["worksheetID"];
$taskName = $seolistRow["taskName"];
$taskInfo = $seolistRow["taskInfo"];
if ($taskValue == 1) {
$taskDone = "<input type='checkbox' value='1' class='checkbox' name='checkbox".$worksheetID."' id=checkbox'".$worksheetID."' checked='checked' /><div class='taskinfo'>".$taskInfo."</div>";
}
else {
$taskDone = "<input type='checkbox' value='0' class='checkbox' name='checkbox".$worksheetID."' id='checkbox".$worksheetID."' />";
}
if ($currentTask != $taskName) {
echo "</tr>";
echo "<tr class='tr'>";
echo "<td class='task'>".$taskName."</td>";
}
echo "<td class='tick'>".$taskDone."</td>";
$currentTask = $taskName;
}
echo "</tr>";
?>
© Stack Overflow or respective owner