RE: [PHP] Re: deleting a record.
| From: | Peter Houchin | Date: | Tue, 26 Nov 2002 23:30:48 +0000 |
| Subject: | RE: [PHP] Re: deleting a record. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-126206@lists.php.net to get a copy of this message | ||
Thanks Kyle, got it working like a treat :) for some reason it wasn't
selecting the DB but it is now :D
> -----Original Message-----
> From: Kyle Gibson [mailto:admin@frozenonline.com]
> Sent: Wednesday, 27 November 2002 10:05 AM
> To: php-general@lists.php.net
> Subject: [PHP] Re: deleting a record.
>
>
> > <?
> > // 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"]);
> > }?>
>
> There's an easier way to display this. It should make your life
> easier...made mine.
>
> Take a look:
>
> <?
> // 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)): ?>
> <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><td><font
> class="content">
> <a
> href="<?=$PHP_SELF?>?op=resellers&id=<?=$myrow['id']?>&delete=yes">
> (DELETE)</a></font></td></tr>
> <? endwhile; ?>
>
>
> > 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");
> > }
>
> What you should do here is check to see if $res is failing, simply by
> doing the following:
>
> if(!$res) echo "error";
>
> Then, place an 'exit;' after the header(...) command to see if the
> $delete variable is actually being passed.
>
> --
> Kyle Gibson
> admin(at)frozenonline.com
> http://www.frozenonline.com/
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>