|
-
Oct 16th, 2001, 10:16 AM
#1
Thread Starter
Frenzied Member
PHP retriving all selected items from a SELECT
using the multiple attribute on the select box
with ASP you can do this and it returns ALL selected values
Code:
<%@ Language=VBScript %>
<HTML><HEAD>
</HEAD>
<BODY>
<%
Dim s
s=request("fooditems")
response.write(s)
%>
<form actiopn=m.asp>
<select name='fooditems' size='4' multiple>
<Option value=1>option1</option>
<Option value=2>option2</option>
<Option value=3>option3</option>
<Option value=4>option4</option>
<Option value=5>option5</option>
<Option value=6>option6</option>
<Option value=7>option7</option>
<Option value=8>option8</option>
<Option value=9>option9</option>
</select>
<input type='submit'>
</form>
</BODY></HTML>
How do I do the same in PHP?
Thanks
-
Oct 16th, 2001, 12:03 PM
#2
Monday Morning Lunatic
From the PHP manual:
Code:
PHP also understands arrays in the context of form variables, but only in one dimension. You may, for example, group related variables together, or use this feature to retrieve values from a multiple select input:
Example 7-2. More complex form variables
<form action="array.php" method="post">
Name: <input type="text" name="personal[name]"><br>
Email: <input type="text" name="personal[email]"><br>
Beer: <br>
<select multiple name="beer[]">
<option value="warthog">Warthog
<option value="guinness">Guinness
<option value="stuttgarter">Stuttgarter Schwabenbräu
</select>
<input type="submit">
</form>
Note the name[] syntax
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 17th, 2001, 02:07 AM
#3
Thread Starter
Frenzied Member
Thanks parksie
I was asking on behalf of a friend so I'll pass it on.
-
Oct 17th, 2001, 03:38 AM
#4
Thread Starter
Frenzied Member
parksie
Here's the reply I got when I emailed my friend a link to this page so I though I'd better pass it on: 
Thanks dude, bloody obvious when you think about it!! Doh!! Couldn't find
that anywhere!!
You are a god!!!
Me! I'm the god parksie, not you
-
Oct 17th, 2001, 04:49 PM
#5
Monday Morning Lunatic
I'm a bigger god than you
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|