I don't know how to move the value from each check box to table. The problem is that I can not get the value of $uTitle. To test if the value of it is there, I uncomment the 8th line. I have no idea why it doesn't echo $uTitle.
Second problem is, even if the value was saved, I don't know how to save it into table under column Privacy because under $key aren't just values of uTitle but also of ID.
Code: Select all
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<table>
<?php
echo "
<tr>
<td>Title</td><td>Value</td><td>Privacy</td>
</tr>";
//echo $_POST[$uTitle];
if (isset($_POST)) {
foreach ($_POST as $key => $value )
{
mysql_query ("UPDATE titles SET uValue = '$value' WHERE ID ='$key'");
}
}
$query = "SELECT * FROM titles WHERE UserID = $ID";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
echo "<br /><b>Edit data:</b> <br /><br />";
while($row = mysql_fetch_assoc($result))
{
extract ($row);
echo "
<tr>
<td><b>$uTitle</b></td>
<td><input type='text' name='$ID' value='$uValue'></td>
<td><input type='checkbox' name='$uTitle' value='yes'>
</tr>";
}
?>
<tr><td><input type="submit" value="Update"></td>
</tr>
</table>
</form>
