Show Multiple Checkbox Checked With Multiple Array Using Php

We are telling you by our best web post that how to show multiple checkboxes checked with multiple arrays using PHP Example.

Whenever you can checkbox checked with using the MySQL database then some users say it is the very difficulty not user friendly. but our article through you would easily step by step understand.

how to show multiple checkbox checked in php?

We will get to product information from the database and display different product information with the checkbox. how to display checked checkbox value in php? we selected product information inserts into another database. we need to inserted product information at edit time. because if already exists in the database and then the HTML checkbox should be checked in the edit form. below example in, the select_products array converts into the string with comma sign as well as explode function by string to convert into the array. if match array value after that the HTML checkbox will be checked or the HTML checkbox will be unchecked.

Also Read: PHP Multiple Checkbox Array Handling Tutorial Example

index.php

"Mobile","value"=>1),
	  array("name"=>"Laptop","value"=>2)
	);

       // product information
        $products_detail = array (
		array("name"=>"Mobile","value"=>1),
		array("name"=>"Laptop","value"=>2),
		array("name"=>"DVD","value"=>3),
		array("name"=>"Pendrive","value"=>4)
	);

	$string="";
	foreach ($select_products as  $key => $val) {
		$string .= ',' .$val['value'];
	}
	$string = substr($string,1);
	$string = explode(',',$string);

	foreach ($products_detail as $ld)
        {
		if(in_array($ld['value'],$string))
		{
		?>
		    

Leave a Comment