ok..... here goes nothin... this is my guess at what you're looking for.
Code:
<?php
// Include file for database connection, or put the code
// here
// Table name
$table = "mytable";
echo("Edit:<input type=\"radio\" name=\"action\" value=\"edit\"><br>Delete:<input type=\"radio\" name=\"action\" value=\"delete\"><br>");
echo("<form action=\"edit_delete.php\" method=\"post\">");
$query = "SELECT * FROM $table";
$result = mysql_query($query);
echo("<input type=\"hidden\" name=\"table\" value=\"$table\"><select size=\"1\" name=\"myresults\">");
while($row = mysql_fetch_array($result))
{
$id = $row['ID'];
$myresults = $row['myresults'];
echo("<option value=\"$id\">$myresults");
}
echo("</select><br><input type=\"submit\" name=\"edit_delete\" value=\"Go\"></form><p>");
Use the hiden name "table" if you have to use another page to edit/delete the script. The way that I have it coded, I used an outside page. I would however, in a normal situation have it be
Code:
<form action=\"$PHP_SELF\" method=\"POST\">
Use if to delete and edit...
Code:
if($edit_delete == "Go"){
if($action == "delete"){
// Delete from database where table is $table and
// ID is $myresults
echo("It has been deleted");
}
if($action == "delete"){
// Select from $table where id is $myresults
// Display in form
}
// End if $edit_delete
}
Hope this might help some. You will want to edit my arrays to match your tables. I suggest reading Kevin's tutorial, don't skip over anything, and you will get it!
I just read that a few weeks ago, and already really understand PHP/MySQL. (In fact I have built an entire site out of it... need is the best teacher)
God Bless, let me know if this just made it harder for you to understand.
Alex
Bookmarks