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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nado
Forum Newbie
Posts: 20
Joined: Tue Aug 29, 2006 3:47 am

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

Post 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
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Post 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.
nado
Forum Newbie
Posts: 20
Joined: Tue Aug 29, 2006 3:47 am

Post 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.
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Post 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!
Post Reply