Jump to content

Update checkboxes value.


Gustav

Recommended Posts

Hi guys,

 

I have a small problem, the thing is i whant to load a page which displays the available modules and if it is enabled or not from the database (by showing the checkbox marked). That part works, however when i whant to try to update these fields i have no clue on how to perform that, i´ve tried several things i´ve found on the net but not working. Im a bit of noob in php.

 

The database consist of two rows, module_name and is_enabled. Where is enabled is only 1 or 0 dependingif it is enabled or not.

 

        <FORM action="index.php" method="post">
        <?PHP
	$array_row = mysql_query("SELECT * FROM check_modules");
	while($row = mysql_fetch_array($array_row)){
		$module_name = $row["Module_name"];
		$array_enabled = mysql_query("SELECT is_enabled FROM check_modules where Module_name='$module_name'");
		$enabled = mysql_fetch_array($array_enabled);
		$db_box1 = $row["is_enabled"];
		if($db_box1 == 1)  {$set_checked = "CHECKED";}
			else{$set_checked  =  "";} 
		print "<input type=\"checkbox\"  NAME=\"check[]\"  VALUE=\"$db_box1\" $set_checked/> $module_name <br>";
		$set_checked = ""; 
	} 
	?> 
        <br>
        <input type="submit" name="submit" value="Submit" />
</FORM>

 

Im stuck here i dont know how to check if the boxes are checked or not and when submit is pressed update the is_enabled field with either 1 or 0.

 

With regards,

 

Gustav

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.