Well, to edit and delete, I use separate scripts than the display and insert scripts. I'll show the basics of them, and what you need to change in them to reflect your own db.
Make a simple html page, with a form pointed to update.php. I just put in the row id number. For example...
<form action=update.php method=post>
Id number
<input type=text name=idedit size=20>
<input type=submit value=submit>
You just have to know the row number of the entry you want to edit.
Make a page called update.php, using the same connection process at the beginning of the script as your insert script. This is the one I use, you'll have to change the $variables (fname, lname, etc) to match your own information fields, and the display areas....
php
Connection process
$query=("SELECT* FROM table_name WHERE id='$idedit'");
$result=mysql_query($query);
$num=mysql_num_rows($result);
mysql_close();
$i=0;
while ($i < $num) {
$id=mysql_result($result,$i,"id");
$fname=mysql_result($result,$i,"fname");
$lname=mysql_result($result,$i,"lname");
$dept=mysql_result($result,$i,"dept");
$email=mysql_result($result,$i,"email");
$phone=mysql_result($result,$i,"phone");
?>
//Displays what is in the row
<form action="updated.php">
<input type="hidden" name="ud_id" value="<? echo "$id"; ?>">
<font face=verdana, times size=2><b>
First Name:<br>
<input type="text" name="ud_fname" value="<? echo "$fname"?>"><br>
Last Name:<br>
<input type="text" name="ud_lname" value="<? echo "$lname"?>"><br>
Department/Position:<br>
<input type="text" name="ud_dept" value="<? echo "$dept"?>"><br>
Email:<br>
<input type="text" name="ud_email" value="<? echo "$email"?>"><br>
Phone:<br>
<input type="text" name="ud_phone" value="<? echo "$phone"?>"><br>
<input type="Submit" value="Update">
</form></td>
<?
++$i;
}
?>
As I said, you need to change some areas, but keep the same structure, its fairly easy to understand. Now create a page called updated.php. This is referenced above in the update script. The update.php script will find the information already in the row and displays it, the updated.php script makes the actual changes.
updated.php
php
connection process
$query=("UPDATE table_name SET fname='$ud_fname', lname='$ud_lname', dept='$ud_dept', email='$ud_email', phone='$ud_phone' WHERE id='$ud_id'");
mysql_query($query);
echo "Contact Info Updated";
mysql_close();
echo "<meta http-equiv=\"refresh\" content=\"0; url=edited.html\" />\n";
?>
Again, look at the query section, and make it match the fields that you have already in your row. Make sure that the ud_id is the same in update.php & updated.php. The section at the bottom is not necessary, its simply a redirecton, so that after updating I go to another page.
I'll put the delete script in the next post.