I'm relatively new to PHP although I do feel I've got a grasp of the
basics. I have used php to draw up numerous selection lists populated
from a mysql database and have had no trouble at all.
However when it comes to the same concept yet using HTML check boxes I
aM complety stumped. It seems easy but I've been staring at the same
problem for hours.
Any hints are greatly appreciated.
Thanks
Haig
Sent from my iPhone
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Ckeckbox list populated from database
am 20.09.2009 07:47:40 von Paul M Foster
On Sat, Sep 19, 2009 at 09:06:14PM -0700, Haig Davis wrote:
> Hello List,
>
> I'm relatively new to PHP although I do feel I've got a grasp of the
> basics. I have used php to draw up numerous selection lists populated
> from a mysql database and have had no trouble at all.
>
> However when it comes to the same concept yet using HTML check boxes I
> aM complety stumped. It seems easy but I've been staring at the same
> problem for hours.
>
> Any hints are greatly appreciated.
I don't know what type of field you're trying to use to populate the
checkbox, but it basically comes down to this:
echo 'checked="checked"'; ?>/>
or
? 'check="checked"' : ''; ?>/>
You've got to decide what is "checked" and "unchecked" for your
checkbox, and then make that a condition which triggers a "checked" or
"unchecked" state for the box. If you like, you can also put a
value="something" attribute in the input tag as well.
When your user is finished inputting the form and you go to process the
results, you can check for the existence of the checkbox name in the
$_POST variable, or check that the $_POST variable contains the value
you set in the value="something" attribute.
Checkboxes and radio buttons are tricky in this way, because they don't
normally return values in the same way an field
does.
Paul
--
Paul M. Foster
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
Regards,
Saeed Ahmed
Rajshahi, Bangladesh
Blog: http://saeed05.wordpress.com
--
Follow Me Linkedin Twitter
--0016367f94b4729e1b0473fd5339--
Re: Ckeckbox list populated from database
am 20.09.2009 16:47:55 von TedD
At 9:06 PM -0700 9/19/09, Haig Davis wrote:
>Hello List,
>
>I'm relatively new to PHP although I do feel I've got a grasp of the
>basics. I have used php to draw up numerous selection lists
>populated from a mysql database and have had no trouble at all.
>
>However when it comes to the same concept yet using HTML check boxes
>I aM complety stumped. It seems easy but I've been staring at the
>same problem for hours.
>
>Any hints are greatly appreciated.
>
>Thanks
>
>Haig
>
>Sent from my iPhone