Insert , Update , Delete in mysql using php
In this example, CRUD operation (Insert,update,delete,view Record) is describe here. As we enter data in textbox , that data will be stored in the database which is created in mysql. We can update record. If record is available in the database table then we can update otherwise we can't update record. We can delete record by adding first name in this example. To make attractive look of form, in this example materialize css is used in the example .Let's see the example :
Output :
Output :
Output :
Note :
Database Name : dbmultiple
Table Name : users
Field Name : first_name,last_name
CSS Download link : Click Here
File Name :- insert.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | <?php $servername= "localhost"; $username = "root"; $password=""; $dbname="dbmultiple"; $conn = new mysqli($servername,$username,$password,$dbname); if($conn->connect_error) { die("Connection Failed".$conn->connect_error); } if(isset($_POST['cancel'])) { $fn = $_POST["fname"]; $ln = $_POST["lname"]; $fn=""; $ln=""; } if(isset($_POST['insert'])) { $fn = $_POST["fname"]; $ln = $_POST["lname"]; $sql = "INSERT INTO users(first_name,last_name) VALUES ('".$fn."','".$ln."')"; if($conn->query($sql)===TRUE) { echo "Record Insert Successfully"; } else { echo "Error :".$sql."<br>".$conn->error; } } $conn->close(); ?> <html> <head> <link rel="stylesheet" href="css/materialize.css"/> <link rel="stylesheet" href="css/materialize.min.css"/> </head> <body> <center> <form method="POST" > <div class="row"> <div class="input-field col s6"> <input type="text" name="fname" placeholder="Enter First Name" required><br/> <input type="text" name="lname" placeholder="Enter Last Name" required><br/> <input type="submit" name="insert" value="Insert" class="waves-effect waves-light btn"> <input type="submit" name="cancel" value="Cancel" class="waves-effect waves-light btn"> </div> </form> </center> <script type="text/javascript" src="js/materialize.js"/> <script type="text/javascript" src="js/materialize.min.js"/> </body> </html> |
Output :
File Name : update.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | <?php $servername= "localhost"; $username = "root"; $password=""; $dbname="dbmultiple"; $conn = new mysqli($servername,$username,$password,$dbname); if($conn->connect_error) { die("Connection Failed".$conn->connect_error); } if(isset($_POST['cancel'])) { $fn = $_POST["fname"]; $ln = $_POST["lname"]; $fn=""; $ln=""; } if(isset($_POST['update'])) { $fn = $_POST["fname"]; $ln = $_POST["lname"]; $sql = "UPDATE users SET last_name='$ln' WHERE first_name='$fn'"; if($conn->query($sql)===TRUE) { echo "Record UPDATE Successfully"; } else { echo "Error :".$sql."<br>".$conn->error; } } $conn->close(); ?> <html> <head> <link rel="stylesheet" href="css/materialize.css"/> <link rel="stylesheet" href="css/materialize.min.css"/> </head> <body> <center> <form method="POST" > <div class="row"> <div class="input-field col s6"> <input type="text" name="fname" placeholder="Enter First Name" required><br/> <input type="text" name="lname" placeholder="Enter Last Name" required><br/> <input type="submit" name="update" value="Update" class="waves-effect waves-light btn"> <input type="submit" name="cancel" value="Cancel" class="waves-effect waves-light btn"> </div> </form> </center> <script type="text/javascript" src="js/materialize.js"/> <script type="text/javascript" src="js/materialize.min.js"/> </body> </html> |
File Name : delete.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | <?php $servername= "localhost"; $username = "root"; $password=""; $dbname="dbmultiple"; $conn = new mysqli($servername,$username,$password,$dbname); if($conn->connect_error) { die("Connection Failed".$conn->connect_error); } if(isset($_POST['cancel'])) { $fn = $_POST["fname"]; $ln = $_POST["lname"]; $fn=""; $ln=""; } if(isset($_POST['delete'])) { $fn = $_POST["fname"]; $sql = "DELETE FROM users WHERE first_name='$fn'"; if($conn->query($sql)===TRUE) { echo "Record DELETE Successfully"; } else { echo "Error :".$sql."<br>".$conn->error; } } $conn->close(); ?> <html> <head> <link rel="stylesheet" href="css/materialize.css"/> <link rel="stylesheet" href="css/materialize.min.css"/> </head> <body> <center> <form method="POST" > <div class="row"> <div class="input-field col s6"> <input type="text" name="fname" placeholder="Enter First Name" required><br/> <input type="submit" name="delete" value="Delete" class="waves-effect waves-light btn"> <input type="submit" name="cancel" value="Cancel" class="waves-effect waves-light btn"> </div> </form> </center> <script type="text/javascript" src="js/materialize.js"/> <script type="text/javascript" src="js/materialize.min.js"/> </body> |
Note :
Database Name : dbmultiple
Table Name : users
Field Name : first_name,last_name
CSS Download link : Click Here
CRUD operation using mysql in php, database connectivity in php, delete record using mysql in php, Insert record using mysql in php, Php Tutorial, update record using mysql in php
This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic.
ReplyDeleteRegards,
PHP Institutes in Chennai|PHP Training Center in Chennai
ReplyDeleteI wish to show thanks to you just for bailing me out of this particular trouble.As a result of checking through the net and meeting techniques that were not productive, I thought my life was done.
Advanced Selenium Training in Chennai
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteYour new valuable key points imply much a person like me and extremely more to my office workers. With thanks; from every one of us.
ReplyDeleteAWS Online Training
I am a regular reader of your blog and being students it is great to read that your responsibilities have not prevented you from continuing your study and other activities. Love
ReplyDeleteClick here:
angularjs training in velarchery
Click here:
angularjs training in sholinganallur
I was looking for this certain information for a long time. Thank you and good luck.
ReplyDeleteClick here:
Microsoft azure training in bangalore
Click here:
Microsoft azure training in pune
I am really happy with your blog because your article is very unique and powerful for new reader.
ReplyDeleteClick here:
Selenium Training in Chennai | Selenium Training in Bangalore | Selenium Training in Pune | Selenium Training in Chennai
Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.
ReplyDeletebest rpa training in chennai |
rpa training in chennai |
rpa training in bangalore
rpa training in pune | rpa online training
Thanks for the informative article. This is one of the best resources I have found in quite some time. Nicely written and great info. I really cannot thank you enough for sharing.
ReplyDeleteData Science training in Chennai | Data science training in bangalore
Data science training in pune | Data science online training
Data Science Interview questions and answers | Python training in Kalyan nagar
Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
ReplyDeleteangularjs online Training
angularjs Training in marathahalli
angularjs interview questions and answers
angularjs Training in bangalore
angularjs Training in bangalore
angularjs online Training
Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information.
ReplyDeleteSelenium training in Chennai
Selenium training in Bangalore
Selenium training in Pune
Selenium Online training
After reading your post I understood that last week was with full of surprises and happiness for you. Congratz! Even though the website is work related, you can update small events in your life and share your happiness with us too.
ReplyDeletepython Training in Pune
python Training in Chennai
python Training in Bangalore
Read all the information that i've given in above article. It'll give u the whole idea about it.
ReplyDeleteData Science course in Indira nagar
Data Science course in marathahalli
Data Science Interview questions and answers
Data science training in tambaram
Data Science course in btm layout
Data science course in kalyan nagar
Data science course in bangalore
Really you have done great job,There are may person searching about that now they will find enough resources by your post
ReplyDeleteMicrosoft Azure online training
Selenium online training
Java online training
Python online training
uipath online training
Hi,
ReplyDeleteGood job & thank you very much for the new information, i learned something new. Very well written. It was sooo good to read and usefull to improve knowledge. Who want to learn this information most helpful. One who wanted to learn this technology IT employees will always suggest you take python training in bangalore. Because Python course in Bangalore is one of the best that one can do while choosing the course.
very good
ReplyDeleteinplant training in chennai
inplant training in chennai for it
Bermuda web hosting
Botswana hosting
armenia web hosting
dominican republic web hosting
iran hosting
palestinian territory web hosting
iceland web hosting
good
ReplyDeleteBermuda web hosting
Botswana hosting
armenia web hosting
lithuania shared web hosting
inplant training in chennai
inplant training in chennai for it
suden web hosting
tunisia hosting
uruguay web hosting
Get enrolled for the most demanding skill on the Data Science Training in Hyderabad will make your career a new height. We at Analytics Path provide you with an excellent stage to learn and explore the subject from industry experts. We help students to dream high and achieve it.
ReplyDeleteFor More Info Data Science Training In Hyderabad
Great blog created by you. I read your blog, its best and useful information. Super blogging and keep it updating
ReplyDeleteBlockchain Training in Hyderabad
Nice Blog. the Blog is really very Impressive and its explained the every concept should be unique and clearly Explained.
ReplyDeleteData Science Training Course In Chennai | Data Science Training Course In Anna Nagar | Data Science Training Course In OMR | Data Science Training Course In Porur | Data Science Training Course In Tambaram | Data Science Training Course In Velachery
Big Thanks for this wonderful read. I enjoyed every little bit of reading and I have bookmarked your website to check out new stuff of your blog a must read blog.good luck.
ReplyDeleteAi & Artificial Intelligence Course in Chennai
PHP Training in Chennai
Ethical Hacking Course in Chennai Blue Prism Training in Chennai
UiPath Training in Chennai
nice article...We are providing best training to students.Thanks!!
ReplyDeleteandroid training in chennai
android online training in chennai
android training in bangalore
android training in hyderabad
android Training in coimbatore
android training
android online training
android training in chennai
android online training in chennai
android training in bangalore
android training in hyderabad
android Training in coimbatore
android training
android online training
I just recently discovered your blog and have now scrolled through the entire thing several times. I am very impressed and inspired by your skill and creativity, and your "style" is very much in line with mine. I hope you keep blogging and sharing your design idea
ReplyDeletedata science training in chennai
data science training in velachery
android training in chennai
android training in velachery
devops training in chennai
devops training in velachery
artificial intelligence training in chennai
artificial intelligence training in velachery
I hope i will find more interesting blog from you. I also like to share something interesting. thanks a lot.
ReplyDeletejava training in chennai
java training in annanagar
aws training in chennai
aws training in annanagar
python training in chennai
python training in annanagar
selenium training in chennai
selenium training in annanagar
Very useful post. This is my first time I visit here. I found so many interesting stuff in your blog especially its discussion. Really its great article.Thanks for sharing!!
ReplyDeleteweb designing training in chennai
web designing training in tambaram
digital marketing training in chennai
digital marketing training in tambaram
rpa training in chennai
rpa training in tambaram
tally training in chennai
tally training in tambaram
Appreciation for really being thoughtful and also for deciding on certain marvelous guides most people really want to be aware of.
ReplyDeletehardware and networking training in chennai
hardware and networking training in omr
xamarin training in chennai
xamarin training in omr
ios training in chennai
ios training in omr
iot training in chennai
iot training in omr
Awesome blog it's very nice and useful i got many more information it's really nice i like your blog
ReplyDeleteAI Training in Hyderabad
ExcelR provides data scientist course in pune . It is a great platform for those who want to learn and become a data scientist. Students are tutored by professionals who have a degree in a particular topic. It is a great opportunity to learn and grow.
ReplyDeletedata scientist course in pune
Attend The Business Analytics Course From ExcelR. Practical Business Analytics Certification Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Business Analytics Course
ReplyDeleteData Scientist Course
Thanks for the post. It was worth reading.
ReplyDeleteSQL training in Pune