select multiple tag problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jito
Forum Commoner
Posts: 85
Joined: Sat Mar 25, 2006 4:32 am
Location: india

select multiple tag problem

Post by jito »

i am having a problem with the following multiple select tag. my code is as follows:

Code: Select all

test.php


<?php

foreach($sel as $val)
print "$val<br>";

?>
<FORM METHOD=POST ACTION=test.php>
<select multiple name=sel>
<option value=1>one</option>
<option value=2>two</option>
<option value=3>three</option>
<option value=4>Four</option>
</select>
<input type=submit value=submit>
</form>
when this page is executed i am getting an error as invalid argument supplied to foreach
if i give multiple select as
<select multiple name=sel[]>
my code is executing and showing the selected values.
but i want to execute my code with
<select multiple name=sel>
is there any way out
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

is there an actual reason behind wanting to not use sel[]?

viewtopic.php?t=45711 may be of interest.
jito
Forum Commoner
Posts: 85
Joined: Sat Mar 25, 2006 4:32 am
Location: india

Post by jito »

hi,
i have seen it working somewhere but i'm not able to use it. i just want to know is it possible to do so.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

if you read the thread I linked to, you'll get your answer.
Post Reply