Forum Moderators: coopster
$subselect="select * from topics order by seekwense";
$topicss=mysql_query($subselect) or die( mysql_error());
$ilcv=0;
while ($row1=mysql_fetch_array($topicss))
{
$thissequence=$row1['seekwense'];
$thislabel=$row1['disscussion'];
echo"<label for $thislabel> $thislabel</label>\n";
echo"<input type='checkbox' name='topic' value=$thissequence id=$thislabel />\n";$ilcv++;
if ($ilcv>=4)
{
echo"</p><p>";
$ilcv=0;
}
}
Anyway... say I have 20 topics, and I check off anywhere from 1 to 20 boxes. Does topic store them as an array of true /false items in a array? When preparing to save my post the data tables, can I cycle through the array and store the checkboxes that were checked?
Is it possible to have a checkbox that says "go ahead and ad another?"
Thanks
<input type="checkbox" name="somename[1]">
<input type="checkbox" name="somename[2]">
this will create an array of variables in $_POST which is visible when you do
var_dump($_POST['somename'])
mind, that only the checkboxes that are checked will appear in this array. the ones without checkmark will simply not exist in that array.
echo '<input type="checkbox" name="topic[]" value="'.$thissequence.'" id="'.$thislabel.'" />'."\n";
Notice how I changed the name to topic[] and also correctly added the quotes around each of the attributes. On the action page try the following:
echo '<pre>'; print_r($_POST['topic']); echo '</pre>';