Re: problem in checkbox

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello usman,

know this is late , but still hope that this will be helpful for others too

edit and use

-----------------------------------------------------------------------
if(isset($_POST[checkbox]) && $_POST[checkbox] != NULL )
                     {
                    foreach($_POST['checkbox'] as $key=>$id)
                     { 
                              
                            
                            $prod_id = $_POST['id'][$key];
                            
                            $QRY_Del="DELETE FROM table WHERE Pid='$prod_id' '";
                            
                            $Res=mysql_query($QRY_Del);
            
                    
                     }
                     
                     }
                     



Thanks,

     Reji,
     PHP Developer.




--- On Tue, 23/6/09, Usman ali <usman.a.a@xxxxxxxxx> wrote:

From: Usman ali <usman.a.a@xxxxxxxxx>
Subject: Re:  problem in checkbox
To: php-objects@xxxxxxxxxxxxxxx
Date: Tuesday, 23 June, 2009, 11:58 AM











    
            
            


      
      Hi,

in form use [] after the variable name to get the selected values



eg:



html:



<input name="records[ ]" type="checkbox"  value="12" />

<input name="records[ ]" type="checkbox"  value="17" />

<input name="records[ ]" type="checkbox"  value="33" />

<input name="records[ ]" type="checkbox"  value="32" />



phpcode:



$records = isset($_POST[ 'records' ])? $_POST['records' ]: ''; // this will

return an array



if (count($records) >0){



$records = implode($records, ','); // will result in string value of

12,17,33,32

$deletesql = 'Delete * from mytable where recordids in (' . $records .')';



}



you may need to do your validations in the above code.



hope this helps!!!



Usman AA



2009/6/23 ozgur teksin <ozgur.teksin@ gmail.com>



>

>

> I agree on Joe as well. Post your non working code.

>

>

> On Sun, Jun 21, 2009 at 11:38 PM, Khizra Ali <khizra_php@yahoo. com<khizra_php% 40yahoo.com> >

> wrote:

>

> >

> >

> > i want to delete some records through multiple checkboxes.. .

> > i write a code but it is not working

> > plz give me some suggestion..

> > thank in advance.

> >

> > [Non-text portions of this message have been removed]

> >

> >

> >

>

> [Non-text portions of this message have been removed]

>

>  

>



-- 

Usman A A



[Non-text portions of this message have been removed]




 

      

    
    
	
	 
	
	








	


	
	


      Cricket on your mind? Visit the ultimate cricket website. Enter http://cricket.yahoo.com

[Non-text portions of this message have been removed]


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux