AdonaiEchad wrote:
> registration where they ask for what is your favorite
sports and there is a
> list of checkboxes and at the bottom there is a check
box that says all and
> some how you see the checkbox has a check mark in all
the boxes. How is this
> set up within PHP or I guess it will be HTML form tag.
It's not done with PHP, but JavaScript. Do a Google search.
You'll find
plenty of scripts.
> What I do not
> understand is what is the structure that if you have
more than one checkbox
> which can be different interests, how does that get
applied to the database of
> MySQL, is it a VARCHAR, or INT or even LONGTEXT?
Use a SET as the MySQL column type:
http://dev.mysql.com/doc/refman/5.0/en/set.html
All checkboxes should have the same name followed by an empty
pair of
square brackets so that they form an array. For example:
<input type="checkbox" name="interests[]" value="tennis"
/>
If no checkbox is selected, $_POST['interests'] will not
exist, so you
need to test for its existence, and then use implode() to
turn it into a
string before passing it to the SQL query.
if (isset($_POST['interests'])) {
$interests = implode(',', $_POST['interests']);
}
else {
$interests = '';
}
--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/