Skip to main content

CURD Operation In Php, update,delete,display,insert.etc

Display Code 



<?php

$dbservername="localhost";
$dbusername="root";
$dbpassword="";
$dbname="test_curd";

$con=mysqli_connect($dbservername,$dbusername,$dbpassword,$dbname);

if ($con) {
# code...

// echo "Connection is set";

// DISPLAY CODE HERE

$sql=" select * from curd_table";

$res=mysqli_query($con,$sql);//query fired

// print_r($res);//human can read this statement

if (mysqli_num_rows($res) >0)
{
# code...
$x=mysqli_fetch_assoc($res);

/*
echo $x['username'];
echo "<br/>";
echo $x['password'];

*/
print_r($x);
}
}
else{

echo "Something Went Wrong";

}




?>



Insert code



<?php 
session_start();
session_destroy();
 ?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Insert php</title>
</head>
<body>


<div style="margin-left:35%; margin-top:20%; margin-right:35%;">

<form action="" method="POST">
<input type="text" name="username" placeholder="Enter your Name...." style="height:20px; width:100%; border-radius:20px; outline-color: none; outline: none;">
<br><br>
<input type="password" name="password" placeholder="Enter your password...." style="height:20px; width:100%; border-radius:20px; outline: none;outline-color: none;">
<br><br>
<div style="margin-left:35%;">
<input type="submit" name="submit" value="Insert" style="padding: 5px;">

</div>


</form>
</div>
</body>
</html>

<?php 
$dbservername="localhost";
$dbusername="root";
$dbpassword="";
$dbname="test_curd";
$con=mysqli_connect($dbservername,$dbusername,$dbpassword,$dbname);

if ($con) {
# code...
// echo "Connection Is Successfull";

if (isset($_POST['submit'])) {
# code...
$username=$_POST['username'];
$password=$_POST['password'];

$sql="Insert into curd_table(username,password) value('$username','$password')";
$res=mysqli_query($con,$sql);
if ($res) {
# code...
echo "Successfull data inserted";
}
}


}
else{

echo "something went wrong ";
}








 ?>




Update code


<?php 

$dbservername="localhost";
$dbusername="root";
$dbpassword="";
$dbname="test_curd";

$con=mysqli_connect($dbservername,$dbusername,$dbpassword,$dbname);

if ($con) {
# code...
// echo "Connection is succssfull ";

$sql="update curd_table set username='Kajol',password='kachhap' where id=2";//sql statement here 
$res=mysqli_query($con,$sql);

if ($res) {
# code..
// print_r($res); Human can read this statement 
echo "succssfully Done!";
}


}
else{

echo "Something went wrong";
}



 ?>




Delete Code



<?php 

$dbservername="localhost";
$dbusername="root";
$dbpassword="";
$dbname="test_curd";

$con=mysqli_connect($dbservername,$dbusername,$dbpassword,$dbname);

if ($con) {
# code...
// echo "Connection is set";
$sql="delete from curd_table where id=1";
$res=mysqli_query($con,$sql);
// print_r($res); //Human can read this sql statement 
if ($res) {
# code...
echo "Successfully Done!";
}

}
else{

echo "Something Went Wrong";
}

 ?>











Comments

Popular posts from this blog

Login system in Php With HTML code

                                {== HTML  CODE HERE ==}   <!DOCTYPE html>   <html>     <head>       <!--Import Google Icon Font-->       <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">       <!--Import materialize.css-->       <link type="text/css" rel="stylesheet" href="css/materialize.min.css"  media="screen,projection"/>       <!-- online cdn -->        <!-- Compiled and minified CSS -->     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">     <!-- Compiled and minified JavaScript -->     <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0...

Python some code With Rajeev Minj

#print(" Hello Class! I'm Rajeev Minj Code with Rajeev") #print("Subscribe My Youtube channel And like,share " # "like my facebook page and fllow on instagram ") # This is single line comment This is Multiline Comments """" This is Multiline Comments in python language """ #print("Hello Rajeev Minj","hello World Some thing Went wrong") #print("print statement new line create karta hain","Or Display karta hain") #print("c:\rajeev") #print("c:\\rajeev")# This is Escape Sequences statements #print("Rajeev is \n a good boy \t 1") """ *Varibles, Datatype and Typecastiong|Python Tutorials For absolute For Biginners var1 ="Hello Rajeev How can i help you ?" #this is string value in python var4 = "Hi Rajeev Minj" var2 = 40 #this is int value in python var3 = 10.5 #this is float val...

Quotes for lovers in Hindi||English, love quotes in Hindi English,||प्यार भारा शायरी

 Hindi Love Quotes in Hindi English ❤️❤️👇😎 quotes of love  1."Pyaar mein koi age nahi hoti, pyaar mein sirf vishvas hota hai." (There is no age in love, there is only trust in love.)❣️❣️ 2."Pyaar karne wale har waqt saath nahi hote, magar pyaar unki yaad mehsoos hota hai." (Lovers are not always together, but love is felt in their memories.)💞💞 quotes of love 3."Pyaar ek aisa rishta hai, jo dil se hota hai, aur dil se hi nibhana chahiye." (Love is a relationship that comes from the heart and should also be maintained from the heart.)💗💗 4."Pyaar to sachcha pyaar hai, jab do dil ek dusre ko samjhte hai, aur ek dusre ke liye apni zindagi luta dete hai." (Love is true love when two hearts understand each other and sacrifice their lives for each other.)🥰🥰 5."Pyaar ka asar kitna bhi chhota na ho, woh toh hamesha zinda rehta hai." (The effect of love may be small, but it always remains alive.)🥰💗💞❣️Hindi Love Quotes for lovers  quotes...