Hii
Hii
<?php
$con= new mysqli('localhost','root','','crudop');
if(isset($_POST['submit'])){
$name=$_POST['name'];
$email=$_POST['email'];
$mobile=$_POST['mobile'];
$password=$_POST['password'];
//insert query
$sql = "INSERT INTO leo( name, email, mobile, password )
VALUES( '$name', '$email','$mobile', '$password' )";
//execute query
$result=mysqli_query($con,$sql);
// we will check
if($result) {
echo "data inserted successfully";
header('Location:display.php');
}else{
die(mysqli_error($con));
}
}
?>
display
<?php
$sql="Select * from leo";
$result=mysqli_query($con,$sql);
if ($result){
//step 1
// $row=mysqli_fetch_array($result);
// echo $row['name'];
while ($row=mysqli_fetch_array($result))
{
$id=$row['id'];
$name=$row['name'];
$email=$row['email'];
$mobile=$row['mobile'];
$password=$row['password'];
echo'<tr>
<th scope="row">'.$id.'</th>
<td>'.$name.'</td>
<td>'.$email.'</td>
<td>'.$mobile.'</td>
<td>'.$password.'</td>
<td>
update
<?php
$con= new mysqli('localhost','root','','crudop');
$id = $_GET['updateid'];
if(isset($_POST['submit'])){
$name=$_POST['name'];
$email=$_POST['email'];
$mobile=$_POST['mobile'];
$password=$_POST['password'];
$result=mysqli_query($con,$sql);
if($result) {
echo "updated successfully ";
header('Location:display.php');
}else{
die(mysqli_error($con));
}
}
?>
delete
<?php
$con= new mysqli('localhost','root','','crudop');
if(isset($_GET['deleteid'])){
$id=$_GET['deleteid'];
//insert query
$sql = "delete from leo where id=$id";
//execute query
$result=mysqli_query($con,$sql);
// we will check
if($result) {
echo "deleted successfully";
header('Location:display.php');
}else{
die(mysqli_error($con));
}
}
?>
insert asp
search asp
delete asp
update asp