Save checkbox in mysql database

StAiN1337

New Member
I want to update table module with a checkbox value, which is given. So when a user checks a checkbox the module in the database has to update from 0 to 1. Right now, i have the following code:\[code\]if($_POST['modulesubmit']){if($_POST['uitgeschakeld']){ mysql_query("UPDATE Modules SET Status = '".mysql_real_escape_string('0')."' WHERE module_name = '".mysql_real_escape_string($_POST['module_name'])."'") or die (mysql_error()); echo'dasd';}elseif($_POST['ingeschakeld']){ mysql_query("UPDATE Modules SET Status = '".mysql_real_escape_string('1')."' WHERE module_name = '".mysql_real_escape_string($_POST['module_name'])."'") or die (mysql_error()); echo'bhal';}} echo "<h1>Module beheer</h1>";$getmodules = mysql_query("SELECT * FROM Modules") or die(mysql_error());echo "<form id='module' method='post'>"; while($fetchmodules = mysql_fetch_array($getmodules)) { echo "<label name='module_name'>".$fetchmodules['module_name']."</label>"; $getstatusoff = mysql_query("SELECT * FROM Modules WHERE module_name = '".$fetchmodules['module_name']."' AND status = 0") or die(mysql_error()); $getstatuson = mysql_query("SELECT * FROM Modules WHERE module_name = '".$fetchmodules['module_name']."' AND status = 1") or die(mysql_error()); if(mysql_num_rows($getstatusoff)) { echo "<input type='checkbox' id='uitgeschakeld' name='uitgeschakeld' value='http://stackoverflow.com/questions/15900814/uitgeschakeld'><br/>"; } elseif(mysql_num_rows($getstatuson)) { echo "<input type='checkbox' id='ingeschakeld' name='ingeschakeld' value='http://stackoverflow.com/questions/15900814/ingeschakeld' checked></br>"; } } echo "<input type='submit' id='modulesubmit' name='modulesubmit' value='http://stackoverflow.com/questions/15900814/Opslaan'> </form>";\[/code\]At this moment the code doesn't update anything. Could you give me some advice on how to make it work?
 
Top