|
Posted by no on 06/21/06 07:12
On Mon, 19 Jun 2006 20:03:36 +0000 (UTC), Harold <harhem@cogeco.ca>
wrote:
>keep in mind in am new to PHP.
>here is a snippet of some of the checkbox options...
>
><tr>
><td><input type=checkbox name=skill04/>Ad Design</td>
><td><input type=checkbox name=skill05/>Animation</td>
><td><input type=checkbox name=skill06/>ASP</td>
></tr>
>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:
<input type="hidden" name="userid" value="'.$userid.'" />
<tr>
<td><input type=checkbox name="skillset[]" value="Ad Design" />Ad
Design</td>
<td><input type=checkbox name="skillset[]" value="Animation"
/>Animation</td>
<td><input type=checkbox name="skillset[]" value="ASP" />ASP</td>
</tr>
.... perhaps :-)
Then in the receiving page:
foreach ( $_post['skillset'] in $key => $value ) {
'INSERT INTO table VALUES
("","'.mysql_escape_string($_post['userid']).'","'.mysql_escape_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.
Navigation:
[Reply to this message]
|