Jump to content

checkbox + sql


nominator

Recommended Posts

hi, i am doing a member system. at the admin panel which have a list of user, has a checkbox each at the side. I did a loop to display all user from db and set the checkbox value to the id accordingly

[code]
$result =mysql_query("Select * from staff");
if($myrow = mysql_fetch_array($result));
{
do{
printf("             <tr>
                <td width=100><span class=text>%s</span></td>
                <td width=100><input type=checkbox name=check value=%s></td>
             </tr>",$myrow[name],$myrow[staff_id]);
            
}while($myrow=mysql_fetch_array($result));
}[/code]

then for my action delete,

[code]    if($action == 'delete')
    {
        $check = $_POST['check'];
        connect();
        mysql_query("Delete from staff where staff_id='$check'");
    }[/code]

i select a few user to delete, but it only delete one...how can i make it delete whatever i checked.
Link to comment
Share on other sites

[code]
$result =mysql_query("Select * from staff");
if($myrow = mysql_fetch_array($result));
{
do{
printf("             <tr>
                <td width=100><span class=text>%s</span></td>
                <td width=100><input type=checkbox name=check[] value=%s></td>
             </tr>",$myrow[name],$myrow[staff_id]);
            
}while($myrow=mysql_fetch_array($result));
}
[/code]

and

[code]

if($action == 'delete')
    {
        $check = $_POST['check'];
        connect();
        if(count($check)) {
             $check_id_list = "(".implode(",",$check).")";
             mysql_query("Delete from staff where staff_id in ".$check_id_list);
         }
          
    }
[/code]
Link to comment
Share on other sites

[!--quoteo(post=378026:date=May 29 2006, 04:19 AM:name=samshel)--][div class=\'quotetop\']QUOTE(samshel @ May 29 2006, 04:19 AM) [snapback]378026[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[code]
$result =mysql_query("Select * from staff");
if($myrow = mysql_fetch_array($result));
{
do{
printf("             <tr>
                <td width=100><span class=text>%s</span></td>
                <td width=100><input type=checkbox name=check[] value=%s></td>
             </tr>",$myrow[name],$myrow[staff_id]);
            
}while($myrow=mysql_fetch_array($result));
}
[/code]

and

[code]

if($action == 'delete')
    {
        $check = $_POST['check'];
        connect();
        if(count($check)) {
             $check_id_list = "(".implode(",",$check).")";
             mysql_query("Delete from staff where staff_id in ".$check_id_list);
         }
          
    }
[/code]
[/quote]
not working..


Warning: implode(): Bad arguments. in /home/itecollege/domains/itecollege.com/public_html/stcc/manager.php on line 36

woops..working le..sorry
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.