Jump to content

Archived

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

romio

Delete.... Link not a submit button

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?

Share this post


Link to post
Share on other sites
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']).

Share this post


Link to post
Share on other sites
you can try using javascript

formname.submit()

HTH

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.