Make each button a separate form, with the id as a hidden value.  Like so:

<div>
<form method='post'>
<p>My first entry</p>
<input type='hidden' name='id' value='1' />
<input type='submit' value='Delete' />
</form>
</div>

<div>
<form method='post'>
<p>My second entry</p>
<input type='hidden' name='id' value='2' />
<input type='submit' value='Delete' />
</form>
</div>

Obviously you'd want something better formatted, but you get the idea.  Then 
on the receiving end, you'd simply "DELETE FROM entries where id=$id;".  That 
is, AFTER you process and clean the submitted id value so that it's not an 
injection risk. :-)

On Sunday 04 June 2006 00:53, George Babichev wrote:
> Thank you for the help guys, but the I guess I kinda have another question.
> So I do assign an id to each blog post, and it is auto_increment, so in my
> blog delete page, it would display all the blog title's and a delete button
> nex to it. So lets say I click delete on the third entry. How would my
> program know to delete THAT entry and not another one?
>
> On 6/3/06, benifactor <[EMAIL PROTECTED]> wrote:
> > when you insert each blog into your database, im assuming your not doing
> > this by hand each and every time, assign each blog an id.
> >
> > in the place you want to delete the blog entries, list all of the blogs
> > titles and ids.
> > and then use mysql(delete);
> >
> > example:
> > <?
> > //create a variable for the delete blog entry of you control panel
> >     if ($view == delete_blog) {
> >         //this should be the value of your submit button
> >         if ($deleteBlog) {
> >             //this is the value of the blog entries to delete
> >             if (!$idblog) {
> >                 //this is your error message, to be displayed if no blog
> > was
> > chosen to delete
> >                 $de = "<font face=tahoma color=black size=1>You Need To
> > Choose a post to delete</font>";
> >              }
> >             else {
> >                 //list the values of the array in which all the blog
> > entries
> > you would like to delete are
> >                 $delBlog = implode(",", $idblog);
> >                     //do the actual deletion
> >                         mysql_query("delete From blogs where id
> > IN($delBlog)") or die(mysql_error());
> >                             //display the succesfull message if the blog
> > entries were deleted
> >                             echo("<font face=tahoma color=black
> > size=1><b><center>blog(s):</b> $delBlog <b>has/have been
> > deleted;</b></b></center>");
> >
> > //now we display the blog entries
> > //plus the sucsessfull message
> > ?>
> >
> > <form method="post">
> > <?php
> > $gn = mysql_query("Select * FROM blogs");
> > while ($d = mysql_fetch_array($gn)) {
> > ?>
> > <INPUT TYPE="checkbox" NAME="idBlog[]" VALUE="<? echo("$d[id]"); ?>"><?
> > echo("<font face=tahoma color=black size=1><b>Post id:</b> $d[id]<b>;</b>
> > <b>Post Title:</b> $d[title]<b>;</b> <b>Posted by:</b>
> > $d[poster]<b>;</b><br>"); ?>
> > <?php
> > }
> > ?>
> > <br><br><input type="submit" name="deleteNerd" value="Delete"
> > class="button">
> > </form>
> > <?php
> > }
> > }
> > else {
> > //display blog entries only
> > ?>
> > <form method="post">
> > <?php
> > $gn = mysql_query("Select * FROM blogs");
> > while ($d = mysql_fetch_array($gn)) {
> > ?>
> > <INPUT TYPE="checkbox" NAME="idBlog[]" VALUE="<? echo("$d[id]"); ?>"><?
> > echo("<font face=tahoma color=black size=1><b>Post id:</b> $d[id]<b>;</b>
> > <b>Post Title:</b> $d[title]<b>;</b> <b>Posted by:</b>
> > $d[poster]<b>;</b><br>"); ?>
> > <?php
> > }
> > ?>
> > <br><br><input type=submit name="deleteNerd" value="Delete"
> > class="button">
> > </form>
> > <?php
> > }
> > ?>
> > this is a very rough example, however you should catch the drift, make
> > your
> > id an array, implode that array and delete all the array data from the
> > database.
> >
> > ----- Original Message -----
> > From: "George Babichev" <[EMAIL PROTECTED]>
> > To: "PHP General list" <php-general@lists.php.net>
> > Sent: Saturday, June 03, 2006 6:40 PM
> > Subject: [PHP] Delete
> >
> > > Hello everyone! I wrote a blog application, but now for the admin
> > > panel,
> >
> > i
> >
> > > am trying to add a feature to delete blog posts. It would show the
> > > title
> >
> > of
> >
> > > the post next to it, and have a delete link which would delete it. How
> >
> > would
> >
> > > I do this? I mean if I have multiple blog entry's, how would I delete
> >
> > them
> >
> > > without using php my admin?

-- 
Larry Garfield                  AIM: LOLG42
[EMAIL PROTECTED]               ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to