checkbox handling

checkbox handling

am 19.06.2006 22:03:36 von Harold

keep in mind in am new to PHP.

here is a snippet of some of the checkbox options...


Ad Design
Animation
ASP

what i want to do is pass a userid( lets call that userid) along with
any of the items that are checked only.




userid is from a text box entry

so if ad design and ASP are only selected i want both of them in the table

user id | skill
----------------
123 | Ad design
123 | ASP


any help appreciated.

Thanks

Re: checkbox handling

am 20.06.2006 19:40:26 von unknown

Post removed (X-No-Archive: yes)

Re: checkbox handling

am 21.06.2006 09:12:37 von no

On Mon, 19 Jun 2006 20:03:36 +0000 (UTC), Harold
wrote:
>keep in mind in am new to PHP.
>here is a snippet of some of the checkbox options...
>
>
>Ad Design
>Animation
>ASP
>
>what i want to do is pass a userid( lets call that userid) along with
>any of the items that are checked only.
>
>userid is from a text box entry
>
>so if ad design and ASP are only selected i want both of them in the table
>
>user id | skill
>----------------
>123 | Ad design
>123 | ASP

The previous poster is correct in saying that checkboxes are only
passed to the receiving form if they have been ticked. So, the trick
would be to set value="'.$userid.'" in the checkbox.

Or even (untested) do this:



Ad
Design
/>Animation
ASP


.... perhaps :-)

Then in the receiving page:

foreach ( $_post['skillset'] in $key => $value ) {
'INSERT INTO table VALUES
("","'.mysql_escape_string($_post['userid']).'","'.mysql_esc ape_string($value]).'")'
}

(obviously put the INSERT into a suitable command. I am assuming the
first field will be an autoincrementing id.)

Apologies if there is some error there - but it's before breakfast so
my brain isn't fully awake! ;-)

Chris R.