Skip to main content

Add, Edit and Delete Record using PHP/MySQL

Language


Simple add,edit,delete record/s using PHP. From this code we learn how to connect, add, edit and delete record from the database.

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Comments

Submitted byAnonymous (not verified)on Tue, 10/25/2011 - 11:23

hello po!! ang galing

Submitted byAnonymous (not verified)on Wed, 11/23/2011 - 18:46

meg hipos hipos ka lang buh tani sugiran mu ko para kada adlaw maview q para mag most popular.... haha c ian bla naton i post ya ang gin manual ya nga jquery to ang ga flip2 nga image hahaha

Submitted byAnonymous (not verified)on Wed, 11/30/2011 - 20:15

this totirial is very usefull for me..

thanks......

Submitted bycarly (not verified)on Wed, 02/29/2012 - 19:50

really helpful for me as a begginer :)

Submitted byrijan (not verified)on Tue, 08/07/2012 - 13:58

hi

Submitted byAnonymous (not verified)on Thu, 12/06/2012 - 21:36

The Add Del Edit Code is cool. It is working very well except for the header("Location:index.php") which can be replaced by
print "<script>";
print " self.location='index.php';";
print "</script>";

Submitted byMrkay (not verified)on Fri, 10/11/2013 - 22:29

In reply to by Anonymous (not verified)

That worked perfect after getting an error message on the page :

Warning: Cannot modify header information - headers already sent by (output started at /some/file.php:12) in /some/file.php on line x

Submitted byAnonymous (not verified)on Wed, 01/16/2013 - 15:10

A very nice, simple and functioning example!

Submitted byAnonymous (not verified)on Tue, 03/05/2013 - 11:13

It was great but I can't seem to run view.php correctly. These messages are displayed:

Notice: Undefined index: BookID in C:\xampp\htdocs\addeditdelete\view.php on line 3

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\addeditdelete\view.php on line 6
Error: Data not found..

Submitted byAnonymous (not verified)on Fri, 07/12/2013 - 00:09

In reply to by Anonymous (not verified)

I was getting the same error, on checking again, I had not changed the database name in the db.php file. I had earlier created a different database to which I imported the books.sql file. So try changing yours too accordingly

Submitted byAnonymous (not verified)on Mon, 03/25/2013 - 21:36

you are a LIFE SAVER!!!!

thanks a lot mate!!!!

Submitted byAnonymous (not verified)on Thu, 04/18/2013 - 22:13

Awesome script thanks!
how can i add picture upload function with this script ?

Submitted byAnonymous (not verified)on Sun, 05/19/2013 - 19:49

hi i have a programing and my delet funtion dose not working
in delete in php
how can i fexit

Submitted byAnonymous (not verified)on Fri, 06/07/2013 - 19:43

Hi man,
This is very useful for beginners, i just searched it for my junior and found this post very useful. Keep it up. Good work

Submitted byAnonymous (not verified)on Mon, 07/08/2013 - 14:50

nice move"...brad

Submitted bytouhid (not verified)on Fri, 08/23/2013 - 16:26

showing problem in index page loine 58
while($test = mysql_fetch_array($result))
can't load why?pls solve my problem..........

Submitted byjeremia katamno (not verified)on Mon, 08/26/2013 - 21:16

In reply to by touhid (not verified)

Maybe you forget to open brackets at the end of statement, because if i am not mistaken is a while loop that one

Submitted bybritney (not verified)on Tue, 10/01/2013 - 21:44

thank you so much...it's so helpful
but i got error on the index file, on line 58..
the bracket it's opened..
please help me..
thank you so much..God bless us

Submitted bymatzone (not verified)on Wed, 10/09/2013 - 21:29

In reply to by britney (not verified)

It's about your MySQL stuff .. make sure your database name, username and password is correct ! You can change it in db.php file ..

Submitted byAnonymous (not verified)on Wed, 10/09/2013 - 19:46

nice

Submitted byRara Sanchez (not verified)on Sun, 12/01/2013 - 23:46

Saved me!! thanx.. :)

Submitted byemsecaoson Sat, 12/14/2013 - 14:38

here also simple php msql add-edit delete...

http://basicwebcodes.blogspot.com/2013/12/another-more-simple-php-mysql-add-edit.html

Submitted byoll (not verified)on Wed, 01/15/2014 - 23:56

Cannot modify header information - headers already sent by

Submitted bysharmi (not verified)on Mon, 03/10/2014 - 13:19

plssssssssssssssssss send code for add,edit,delete in php

Submitted byAnonymous (not verified)on Fri, 03/21/2014 - 16:29

hi, its a good tutorials, but i have a problem, your original code is fine, and then i just change the variable and change the db, its keep getting me an error: undefined index in line 18-21, how should i solve this ? thx if(isset($_POST['save']))
{
$title_save = $_POST['title'];//line 18
$author_save = $_POST['author'];//line19
$name_save = $_POST['name'];//line20
$copy_save = $_POST['copy'];//line21

mysql_query("UPDATE books SET Title ='$title_save', Author ='$author_save',
PublisherName ='$name_save',CopyrightYear ='$copy_save' WHERE BookID = '$id'")
or die(mysql_error());
echo "Saved!";

header("Location: index.php");
}
mysql_close($conn);
?>

Submitted byJCololo (not verified)on Thu, 04/17/2014 - 19:32

Thank a lot.
you saved my time

Submitted by:D (not verified)on Wed, 05/14/2014 - 13:19

TNX bro .. nice coding

Submitted byStephane (not verified)on Sat, 05/17/2014 - 01:39

I have tried to connect it to a user profile management system but I get the same error all the time when I try to edit informations
! ) Warning: mysql_fetch_array() expects parameter 1 to be resource

Submitted byhussay (not verified)on Sat, 05/17/2014 - 04:47

that was amazing code for me i love that keep it up jani

Submitted byvipul19921 (not verified)on Wed, 06/04/2014 - 18:43

thanx
this is very good demo

Submitted byben you (not verified)on Mon, 07/21/2014 - 23:00

before i was here trying

Submitted bynike air max p… (not verified)on Tue, 11/18/2014 - 19:55

Thanks for your diligence within this Jesse. Something with regards to Yext that is certainly value mentioning: if one of typically the partner internet sites has their own own report which is considered ownership of after that this data requires priority.
nike air max pas cher http://www.trackteur.fr/images/nikeairmax/

Submitted byair max pas cher (not verified)on Tue, 11/18/2014 - 19:55

although my very own query now's... it is possible to technique so those with NO- DETECTOR will probably be nevertheless be discovered in spite of their very own counter computer software???? plsss i want to realize MessTracker can be a program provider lets you keep tabs on online/offline/invisible condition associated with just about any bing messenger accounts (max. 2accounts, 3-4 months interval history, twelve minutes diagnostic scan interval)
air max pas cher http://www.lamdyne.com/cache/

Submitted bySmithe903 (not verified)on Fri, 03/13/2015 - 15:42

Hey. Cool post. There's a dilemma together with your website in chrome, and you may want to check this The browser will be the market leader and a huge component of other people will omit your great writing because of this issue. gfdefgabadecakcb

Submitted bykathreen diann (not verified)on Tue, 12/06/2016 - 09:38

Hello Everyone may i ask if how am i going to debug this error it appears everytime i imported the database .sql file in phpmyadmin???? please

Error
SQL query:

--
-- Database: `books`
--
-- --------------------------------------------------------
--
-- Table structure for table `books`
--
CREATE TABLE IF NOT EXISTS `books` (

`BookID` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`Title` VARCHAR( 150 ) NOT NULL ,
`Author` VARCHAR( 150 ) NOT NULL ,
`PublisherName` VARCHAR( 150 ) NOT NULL ,
`CopyrightYear` YEAR( 4 ) NOT NULL ,
PRIMARY KEY ( `BookID` )
) ENGINE = MYISAM DEFAULT CHARSET = latin1 AUTO_INCREMENT =9;

MySQL said: Documentation

#1046 - No database selected

hello everyone may I ask if how am I going to debug this error everytime i imported the database .sql file in phpmyadmin??... please

Error
SQL query:

--
-- Database: `books`
--
-- --------------------------------------------------------
--
-- Table structure for table `books`
--
CREATE TABLE IF NOT EXISTS `books` (

`BookID` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`Title` VARCHAR( 150 ) NOT NULL ,
`Author` VARCHAR( 150 ) NOT NULL ,
`PublisherName` VARCHAR( 150 ) NOT NULL ,
`CopyrightYear` YEAR( 4 ) NOT NULL ,
PRIMARY KEY ( `BookID` )
) ENGINE = MYISAM DEFAULT CHARSET = latin1 AUTO_INCREMENT =9;

MySQL said: Documentation

#1046 - No database selected

Add new comment

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.