Jump to content

Delete.... Link not a submit button


romio

Recommended Posts

In the past i used to delete though the use of a form and a submit button,
[code]
$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();
[/code]
[code]
<td width='25'  class='lign_3'><input type=checkbox name=cb[] value=$id></td>
[/code]
But now i need to use a link instead of a submit button, How can I do that?
Link to comment
https://forums.phpfreaks.com/topic/11078-delete-link-not-a-submit-button/
Share on other sites

[!--quoteo(post=379588:date=Jun 3 2006, 05:12 AM:name=Zanjo)--][div class=\'quotetop\']QUOTE(Zanjo @ Jun 3 2006, 05:12 AM) [snapback]379588[/snapback][/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....

[code]
            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>";
            }
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.