Re: [PHP-DB] Storing duplicate checkbox values

2001-05-17 Thread Szii

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   They're just there to keep Win-based systems from
trying to interpret the code.


$num_items = 80;

for ($x = 0; $x < $num_items; $x++)
{
  echo "
}

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";
   }
}



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]




Re: [PHP-DB] Storing duplicate checkbox values

2001-05-16 Thread John Starkey

> Yeah. I'm gonna have to go with this one. Thanks. But one other question:
> what should the variable be echoing.
>
> <.input type="checkbox" name="cb_name['value']">this here option
>
> if ( $HTTP_POST_VARS ) {
> echo $cb_name['value'];
> }
>
> It's not coming up with anything. (Yeah, the norm applies, the if
> statement in the <.head>, etc, just trying to be brief).
>
> When it's check it should return true right, I've never done checkboxes?

I just got it. Returned "on".

The syntax is:

<.input type="checkbox" name="cb_name[value]">this here option

echo $cb_name['value'];

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]




Re: [PHP-DB] Storing duplicate checkbox values

2001-05-16 Thread John Starkey

Thanks Ron and Miles,

> First off, it sounds to me like you are doing this a non-expandable way.
> Unless you never ever plan to set up a survey again I would not hard code
> columns for each question.

This is one of "those" gigs. Needed to be done a week ago, by the person
that started it, a month ago. And it must be used before June 1.  So
anything goes at this point. The DB was hard-coded when I got here.

> If you are not willing (or being paid enough) to do this properly up front
> well, you will have to go with a sloppy hack where you do something like this
> in the second table:

Yeah. I'm gonna have to go with this one. Thanks. But one other question:
what should the variable be echoing.

<.input type="checkbox" name="cb_name['value']">this here option

if ( $HTTP_POST_VARS ) {
echo $cb_name['value'];
}

It's not coming up with anything. (Yeah, the norm applies, the if
statement in the <.head>, etc, just trying to be brief).

When it's check it should return true right, I've never done checkboxes?

Thanks again,

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]




Re: [PHP-DB] Storing duplicate checkbox values

2001-05-16 Thread Miles Thompson

I'm just winging this off the top of my head.

If you are absolutely sure that the order of the checkboxes will NOT 
CHANGE, and that is a very risky assumption. And assuming that you have an 
array to hold the values for the checked box, why not just store the value 
of the index for each question? Or assign some other arbitrary value to 
each checkbox?

Alternative which does the same thing in less space. Use a drop down list ( 
combo box ) to display the possible answers for each question and store 
some key value for the question.

So much of this is governed by what you want to do with the gathered 
information.

Hope this has been of some help - Miles Thompson

At 06:42 PM 5/16/01 -0600, John Starkey wrote:
>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]




[PHP-DB] Storing duplicate checkbox values

2001-05-16 Thread John Starkey

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]