Checkbox update!
<h2>Todo-list</h2><br /><form action="?action&save=yes" method="post">
<table width=100% border=1 cellspacing=0 cellpadding=10>
<tr>
<td align=left width=5%><strong>Done</strong></td>
<td align=left width=12%><strong>Subject</strong></td>
<td align=left width=50%><strong>Description</strong></td>
<td align=left width=15%><strong>Added by</strong></td>
<td align=left width=15%><strong>Completed by</strong></td>
</tr>
<?php
$q = mysql_query("SELECT * FROM todolist ORDER by id, checked DESC");
while($r = mysql_fetch_array($q)) {
$addedlink = mysql_query("SELECT id FROM users WHERE username = '$r[addedby]'");
$alink = mysql_fetch_array($addedlink);
$completedlink = mysql_query("SELECT id FROM users WHERE username = '$r[completedby]'");
$clink = mysql_fetch_array($completedlink);
?>
<tr>
<td align=left width=4%><input type="checkbox" name="check"<?php if($r["checked"]=="yes"){ echo " checked=\"checked\""; } else { echo ""; } ?>/></td>
<td align=left width=12%><?php echo $r["subject"]; ?></td>
<td align=left width=54%><?php echo $r["description"]; ?></td>
<td align=left width=15%><a href="userdetails.php?id=<?php echo $alink["id"]; ?>"><?php echo $r["addedby"]; ?></a></td>
<td align=left width=15%><a href="userdetails.php?id=<?php echo $clink["id"]; ?>"><?php echo $r["completedby"]; ?></a></td>
</tr>
<?php } ?>
</table><br />
<div style="position:absolute;right:140px;"><input type="button" onclick="document.location.href='?action=add'" class=btn value="Add!" onfocus="blur()" /> <input type="submit" class=btn value="Save!" onfocus="blur()" /></div>
</form>
Jeg har det her script som henter fra MySQL om en "todo opgave" er lavet, hvis checked=yes så er boksen checked... Men hvis jeg så skal opdatere det i databasen så f.eks. men sætter flueben ved 3 eller fjerner ved nogle så skal den skrive yes i checked hvis checked og no i checked hvis ikke! Håber nogle kan hjælpe mig, for har bøvlet med det i lang tid nu og kan ikke få det til at virke.