Update or Delete Multiple Rows Using PHP


Today we are Learning to Update or Delete multiple rows using PHP

We need to delete and update multiple rows in the backend of our website at times. Suppose you can manually delete and update a single project, but in a large project, you have to use delete and update multiple rows.

This can also save our time and we can also make your backend more attractive.

let’s start Update or Delete Multiple Rows Using PHP.

Step 1: Create New Database and Table

Create a new chart named database

Then

Create a new table name for its users and add some value to it.


CREATE TABLE `users` (
  `userId` int(8) NOT NULL,
  `userName` varchar(55) NOT NULL,
  `password` varchar(55) NOT NULL,
  `firstName` varchar(55) NOT NULL,
  `lastName` varchar(55) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Step 2: Create config.php File.

Step 3: Create index.php File.




alert('Insert Data');";
  }else{
    echo "error";
  }
}
?>




Insert Data




 

Insert Your Data

Enter Your UserName
Enter Your Password
Enter Your FirstName
Enter Your LastName

Step 4: Create show_data.php File.

For each user row, we will use checkboxes here and show our data




Users Show Data List




Show your DATA

Username First Name Last Name
" >

Step 5: Create edit_user.php File.




Edit Multiple User



Edit User

Step 6: Create delete_user.php File.

Step 7: Create users.js File.

function setUpdateAction() {
document.frmUser.action = "edit_user.php";
document.frmUser.submit();
}
function setDeleteAction() {
if(confirm("Are you sure want to delete these rows?")) {
document.frmUser.action = "delete_user.php";
document.frmUser.submit();
}
}

Step 8: Create a style.css File.

To make our UI design more attractive we will create a style.css file here and write the style code in it.

body {
font-family:Arial; 
margin: 0;
padding: 0;
}
.insert{ 
	text-align: center; 
}
.insert
table{
	margin: auto;
}
.insert h1{
	text-transform: uppercase;
	color: #000f65;
	font-size: 25px;
}
.show{
text-align: center; 
}
.show table{
margin: auto;
}
.show
h1{
	text-transform: uppercase;
	color: #000fff;
	font-size: 25px;
}
input {
font-family:Arial;
font-size:14px;
}
label{
font-family:Arial;
font-size:14px;
color:#999999;
}
.tblSaveForm {
border-top:2px #999999 solid;
background-color: #f8f8f8;
}
.tableheader {
background-color: yellow;
}
.tablerow {
background-color: #A7D6F1;
color:white;
}
.btnSubmit {
background-color:#fd9512;
padding:5px;
border-color:#FF6600;
border-radius:4px;
color:white;
}
.message {
color: #FF0000;
text-align: center;
width: 100%;
}
.txtField {
padding: 5px;
border:#fedc4d 1px solid;
border-radius:4px;
}
.evenRow {
background-color: #E2EDF9;
font-size:12px;
color:#101010;
}
.evenRow:hover {
background-color: #ffef46;
}
.oddRow {
background-color: #B3E8FF;
font-size:12px;
color:#101010;
}
.oddRow:hover {
background-color: #ffef46;
}
.tblListForm {
border-top:2px #999999 solid;
}
.listheader {
background-color: yellow;
font-size:12px;
font-weight:bold;
}

Update or Delete Multiple Rows Using PHP


Leave a Comment