Add, Edit and Delete Record using PHP/MySQL

Submitted by: 
Language: 
Visitors have accessed this post 191830 times.

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

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

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

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/

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/

before i was here trying

I want to know what are the PHP codings for editing data in database using php tages

thanx
this is very good demo

hi
how to install my pc and after confiqure ur project
can u guide me.

I am jayakumar Web & Desktop Developer Developer.I Wish to join here and improve my knowledge.If u need project and Source code
send me mail me : [email protected]

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

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

TNX bro .. nice coding

Thank a lot.
you saved my time

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);
?>

plssssssssssssssssss send code for add,edit,delete in php

u really want that code?

Cannot modify header information - headers already sent by

Saved me!! thanx.. :)

Thanx .. it's helped me alot!

how can i use dis stuff on my page, hw do i connect them together? Pls, i would b happy if u cn mail me at [email protected]

nice

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

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

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

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

nice move"...brad

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

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

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

Nice and helpfull

you are a LIFE SAVER!!!!

thanks a lot mate!!!!

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..

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

A very nice, simple and functioning example!

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>";

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

really awesome.... nice.. THANKS

can you help me?

hi

YES! thanks!!! :)

thx so much helpful for me

really helpful for me as a begginer :)

this totirial is very usefull for me..

thanks......

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

maro ba hehehehehe

hello po!! ang galing

helpful for beginners!!

INetTutor.com

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.