I have a profile page where user can edit his data. He can also add own titles. Beside every title is also check box. If checked, the value is yes. 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 would know how to save it into table under column Privacy because under $key aren't just values of uTitle but also of ID. <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> PHP:
Do not echo empty variables ( $_POST[$uTitle] ) !! Try this one .. works for me <?php $uTitle = $_POST['uTitle']; echo $uTitle; ?> PHP:
Usually if the user does not checks the checkbox the value is not posted in to PHP $_POST,hope it helps