Jump to content


Photo

Delete.... Link not a submit button


  • Please log in to reply
3 replies to this topic

#1 romio

romio
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 03 June 2006 - 09:43 AM

In the past i used to delete though the use of a form and a submit button,
$find = "SELECT * FROM countries order by ID"; 
$row= mysql_query($find);
$num_rows = mysql_num_rows($row);

if(isset($_POST["delete"]))
{
    for($i=0;$i<$num_rows;$i++)
    {
        $cb = $_POST['cb'];
        $delete_records = $cb[$i];
        $sql = "DELETE FROM countries WHERE ID=$delete_records";
        $result = mysql_query($sql);
    }
}
mysql_close();
<td width='25'  class='lign_3'><input type=checkbox name=cb[] value=$id></td>
But now i need to use a link instead of a submit button, How can I do that?


#2 Zanjo

Zanjo
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 03 June 2006 - 10:12 AM

What exactly does the check box do? If it confirms it then just make one link goto delete.php?confirm=yes and go isset($_GET['confirm']).

#3 seanlim

seanlim
  • Members
  • PipPipPip
  • Advanced Member
  • 355 posts
  • LocationLondon, United Kingdom

Posted 03 June 2006 - 10:50 AM

you can try using javascript

formname.submit()

HTH

#4 romio

romio
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 03 June 2006 - 02:45 PM

[!--quoteo(post=379588:date=Jun 3 2006, 05:12 AM:name=Zanjo)--][div class=\'quotetop\']QUOTE(Zanjo @ Jun 3 2006, 05:12 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
What exactly does the check box do? If it confirms it then just make one link goto delete.php?confirm=yes and go isset($_GET['confirm']).
[/quote]

Basically i am listing some rows from my database, next to each record the checkbox appear, if that check box is selected and the user clicks on the delete link then all checkboxes must be deleted....

            while($row = mysql_fetch_array($query_posts))
            {
                $name = $row['name'];
                $email = $row['email'];
                $message = $row['message'];
                $id = $row['user_id'];
                $length = 27;
                
                    if (strlen($message) <= $length) 
                    {
                        $message = $message;
                    }
                    else
                    {
                    $message = substr($message, 0, $length) . "..";
                    }
                
                echo "<tr>
                        <td width='25'  class='lign_3'><input type=checkbox name=cb[] value=$id></td>
                        <td width='120' class='lign_3'>&nbsp;$current_date</td>
                        <td width='150' class='lign_4'>&nbsp;<a href=\"javascript:popUp('popup.php?&id=$id')\" class='links'>$message</a></td>
                        <td width='80'  class='lign_3'>$name</a></td>
                        <td width='100' class='lign_3'>&nbsp;201.201.201.201</td>
                        <td width='45'  class='lign_3'>P</td>
                        <td width='45'  class='lign_3'>&nbsp;<a href='admin.php?select=7&id=$id' class='links'><img src='template/images/edit.gif' border='0' title='Edit Post'></a></td>
                    </tr>";
            }





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users