CRUD Operation in PHP With Live Example!


What is CRUD?

CRUD operations are basic information manipulation for databases. We’ve already learned a way to perform produce (i.e. insert), read (i.e. select), update, and delete operations in previous chapters. during this tutorial, we’ll produce a straightforward PHP application to perform these operations on a MySQL information table in one place.

What’s CRUD Full Form?

CRUD is a word form for Create, Read, Update, and Delete.

CRUD operation in PHP MySQL

Well, let’s begin by making the table that we’ll use all told of our examples.

  1. Create new Database
  2. Create new table
  3. Create index.php file
  4. Create server.php file
  5. Create style.css file

1.Create new Database

create new database ( crud ). crud is database name.


2.Create new table

create new table ( info ). info is table name.


3.Create index.php file

create an index.php file on your computer and create a form now add PHP in your index.php file and include your server.php file also.






	crud one page
	
	



name address action
edit delete

output:-


4.Create server.php file

now create server.php file in computer and PHP code written first insert query, second view query, third update query, and last four delete query insert in server.php

alert('update')";
				}
		}

// delete record

	if (isset($_GET['del'])) {
		$id = $_GET['del'];
		mysqli_query($db, "DELETE FROM info WHERE id='$id'");
				$_SESSION['msg']  = "address delete";
			header('location:index.php');

	}

//retrieve records
	$results = mysqli_query($db, "SELECT * FROM info");

?>

5.Create style.css file

You add steel.css to make your crud table look good.

body{
	font-size: 20px;
}
table{
	width: 50%;
	margin:30px auto;
	border-collapse: collapse;
	text-align: left;
}
tr{
	border-bottom: 1px solid black;
}
tr, td{
	border: none;
	height: 30px;
	padding: 3px;
}
tr:hover {
	background:#f5f5f5;
}
form{
	width: 50%;
	margin: 50px auto;
	text-align: left;
	padding: 20px;
	border: 1px solid black;
	border-radius: 5px;
}
.input-group{
	margin: 10px 0px 10px 0px;
}
.input-group label{
	display: block;
	text-align: left;
	margin: 3px;
}
.input-group input{
	height: 30px;
	width: 93%;
	padding: 5px 10px;
	font-size: 16px;
	border-radius: 5px;
	border: 1px solid gray;
}
.btn{
padding: 10px;
font-size: 15px;
color: white;
background:#5F9EA0;
border:none;
border-radius: 5px; 
}

}

How to Create CRUD ??

CRUD means is Create, Read, Update, and Delete.

CRUD ( Insert, Show, Update and delete ) in PHP zip.file here Download link.



Leave a Comment