Jump to content

checkbox in php


kadamsurekha

Recommended Posts

hello!

 

i have a checkbox array of some unknown size.its a dynamic array created.

i want to know out of all checkboxes how many r selected and which are they?

and then insert the data in the table based on that.

i hav written the code as follows:-

<?

$no=0;

$friendname= $_POST['friendname'];

$storecount=$_POST['storeid'];

while($no<$storecount)

{

if($friendname[$no])

{

$sql = "INSERT INTO groupfriends (groupid, username) VALUES ('$stid[$no]', '$friendname[$no]')";

 

$result = mysql_query($sql) or die('Query

 

failed. ' . mysql_error());

}

$no=$no+1;

}

?>

 

 

i dont think this will work.it will add all the checkoxes data to the table. i want to insert only of those which r selected.

 

can any1 help me??????????

 

 

thx n regards

Link to comment
https://forums.phpfreaks.com/topic/44669-checkbox-in-php/
Share on other sites

we have to know what's going on to be able to help you. what is the purpose of storeid? what is it used for? is it a checkbox form or is it a dropdown menu? what?

 

and to answer your question, the checkboxes will not be stored in the array unless they were checked to begin with. so you're checkbox array will not store values that were not checked.

Link to comment
https://forums.phpfreaks.com/topic/44669-checkbox-in-php/#findComment-216930
Share on other sites

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.