deleting a record.
| From: | Peter Houchin | Date: | Tue, 26 Nov 2002 22:35:18 +0000 |
| Subject: | deleting a record. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-126194@lists.php.net to get a copy of this message | ||
howdy all,
this should be fairly simple but not turning out to be so am asking for a
little help..
I have a script that fetches all the records in a table and display's them
on the screen.
I get and display the records with the following:
<?
// get the list of resellers from the db
$res = mysql_query("SELECT * FROM resellers ORDER BY id");
// print all records in the DB
while ($myrow = mysql_fetch_array($res)){
echo "<tr><td><div align='center'><font
class=\"content\">".$myrow['id']."</font></div>
</td><td> </td><td><div
align='justify'><font
class=\"content\">".$myrow['company']."</font></div></td>";
printf("<td><font class='content'><a
href=\"%s?op=resellers&id=%s&delete=yes\">(DELETE)</a></font></td></tr>",
$PHP_SELF, $myrow["id"]);
}?>
now when I click on delete it just reloads the page and doesn't delete the
record. I have this code before anything else on the page to handle the
delete...
if($delete){
$res= mysql_query("DELETE FROM resellers WHERE id=$id");
header("Location: admin2.php?op=resellers");
}
I am relying on the $delete and $id to be set by the url link.
any idea's as I'd like to be able to do this with out having to use a form
with hidden vars..
Cheers
Peter
"the only dumb question is the one that wasn't asked"