I got around it by using a "standard" naming scheme.

(This will work if you have LESS than $num_items, but not more.  If you
have LESS, then it'll just hit the "not set" while loop more.)

Oh, ignore the <XMP>  They're just there to keep Win-based systems from
trying to interpret the code.

<XMP>
$num_items = 80;

for ($x = 0; $x < $num_items; $x++)
{
  echo "<INPUT TYPE='checkbox' name='f_checkbox_" . $x . " ' value='$x'>
}

This will give you "$num_items" checkboxes.

Then after the POST/GET, you can do this...

for($x = 0; $x < $num_items; $x++)
{
  $proto = 'f_checkbox_' . $x;
  if (isset($$proto)) // It's checked, therefore it's set - if it's not
checked, it's just not set.
  {
    echo "Set\n";
  }
  else
  {
     echo "Not set\n";
   }
}

</XMP>

This will give you "Set"/"Not Set" lines 80 times.

G'luck..

-Szii

----- Original Message -----
From: "John Starkey" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, May 16, 2001 5:42 PM
Subject: [PHP-DB] Storing duplicate checkbox values


> Ok This one has me stumped.
>
> I'm working on a survey for an author. There is already a total of 35
> questions and their corresponding columns in the main table. She has three
> other questions that have identical checkboxes, 30 each. I want to put
> them in the second table and just make reference to the record_id from the
> main table and the question number, so that I don't end up with 90 columns
> in this second table.
>
> Anyone have any suggestions on a quick way to do this? Obviously the
> checkboxes will need to have unique names, but the columns won't. I'm
> pretty fried on this and ready to take the not so efficient route of
> having 90 columns.
>
> This is a MySQL/PHP4 job.
>
> Thanks,
>
> John
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to