Jump to content

Archived

This topic is now archived and is closed to further replies.

bagnallc

help with form using php

Recommended Posts

Hi all,

i am trying to process a simple checkbox form within a while statement.
form works fine but im having trouble naming the range so that selections can be retrieved

code is

while($checkbox = mysql_fetch_array($qry))
{
echo "<input type='checkbox' name='$checkbox[field]'>" . " " . $checkbox[going] . "<br/>" ;
}

when i try and retrieve name value in page where form sends information i am having problems.

can you suggest how to name each checkbox - there could be any number of checkboxes from 1 to 500?

many thanks.

Share this post


Link to post
Share on other sites
don't realy understand the request :p

but:
shouldn't it be
$checkbox['field'] and $checkbox['going'] with the '' signs?

I guess so...

Share this post


Link to post
Share on other sites
Normally you'd use name='blah[]' and then retrieve it using $_REQUEST['blah'] but since you're using a query, I would assume that's not what you want. My first suggestion would be to use _ instead of a space as a separator between your field and going values as that some values may have a tailing or leading space, causing problems when you try and explode() the values (of course, they might have trailing or leading underscores in which case use something silly like ===?^$;===). Also, checkboxes that have been checked will send as data but unchecked checkboxes will not send instead of having the value of false which would be expected. If you didn't know about this behaviour then that may be your problem.

Share this post


Link to post
Share on other sites
[code]echo "<input type='checkbox' name='check[]' value='" . (isset($checkbox['field']) ? $checkbox['field'] : $checkbox['going']) . "' />";[/code]

Share this post


Link to post
Share on other sites

×

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.