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
https://forums.phpfreaks.com/topic/86117-update-checkboxes-value/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.