How to UPDATE Multiple Selected Checkbox Values in the Database in PHP


Today we see how to update multiple selected checkbox values in a database in PHP, before that you should insert multiple values and if you don’t know how to insert multiple values then I have explained in the previous blog how to do it Is.

How to Insert Multiple Selected Checkbox Values in Database in PHP

Click here

Step 1: Create a new database and create a new table under it

to create a new Database. Database name is abcd.

CREATE TABLE reg (
id int(11) NOT NULL,
username varchar(250) NOT NULL,
email varchar(250) NOT NULL,
language varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

Step 2: Create a index.php File.

Create an index.php file and create a form in it.



 




How To Checkbox Entry Add in PHP 


how to UPDATE multiple selected checkbox values in database in php

Name:
Email:
language: Gujrati
Hindi
English
Marathi

SHOW DATA HERE

id username email lang language
Update

Step 3: Create an update.php File.

Create a update.php file now write the PHP code in it.





	
	
	
		how to insert multiple selected checkbox values in database in php
	



 location.replace('index.php'); " ;
//echo "update";
}else{
echo "error";
}
} 

 
	
$mid=$_GET['id'];
$sql="SELECT * FROM reg WHERE id='$mid' ORDER BY id DESC";
$data=mysqli_query($connect,$sql);
while ($result=mysqli_fetch_array($data)) {
 
$a=$result['language'];
$b=explode(",", "$a");

print_r($b);
 
?>
Name:
Email:
language: >Gujrati
>Hindi
>English
>Marathi

Note:To update multiple selected checkbox values in the database in PHP we have to convert the data from string to array using implode

The implode() function returns a string from the elements of an array


Leave a Comment