Page 1 of 1

After simple code to add, edit, view, delete records

Posted: Sat Sep 02, 2006 1:10 am
by nado
hi

I'm looking for very basic code that will allow me to add, edit, view all and delete database records.

I already have a set number of fields in a single database table, so don't need any dynamic thing to add rows or whatever.

Here's pretty much what I'm after, but it's doing like an inventory thing.

Know of some simple code that just adds a new entry (name, email etc), allows me to edit, delete and view all (preferably in a single php file)?


thanks

Posted: Sat Sep 02, 2006 2:12 am
by andym01480
The purpose of this forum is to help each other learn. Your best bet is to go back to the tutorial you posted a link to. Have a go yourself and come back with some code and a question if it is not working. Then we all learn.

Posted: Sat Sep 02, 2006 2:58 am
by nado
But I find I learn better by looking at how examples work though, rather than following a tutorial.

e.g. I learnt HTML and CSS mainly by viewing the source of pages.

Posted: Sat Sep 02, 2006 5:05 am
by andym01480
I already have a set number of fields in a single database table, so don't need any dynamic thing to add rows or whatever.

Here's pretty much what I'm after, but it's doing like an inventory thing.

Know of some simple code that just adds a new entry (name, email etc), allows me to edit, delete and view all (preferably in a single php file)?
You are confusing your terms somewhat.
If you want to add a new entry - you are adding a new row!

What you want to do is create a index.php file that has a link to add a new row - with a form and ability to add
Structure of add.php

Code: Select all

if (isset($_POST['submitted']{// add the entry

exit();
}
//form with hidden field called submitted
Then you want in the index.php a query that gets all your records and then echos them in a table.
Have two icons - for each row - one to edit and one to delete and make them a link to edit.php or delete.php that passes a variable with the id of that row. Look at phpmyadmin at the browse page of a table. View the source and it will show you what you want to generate.

Come back when you have had a go!