By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,165 Members | 1,928 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,165 IT Pros & Developers. It's quick & easy.

Why wont this access an array???

P: n/a
Can someone please tell me how to access elements from a multiple
selection list? From what ive read on other posts, this is correct. I
keep getting an "Undefined variable" error though...

Form page********************************************** **************
<form action="/process.php" method="get" name="formOne" id="formOne">
<select name="owner[]" size="6" multiple id="owner[]">
<option value="one">one</option>
<option value="two">two</option>
<option value="three">three</option>
</select>
<input type="submit" name="Submit" value="Submit">
</form>
Process page********************************************** ************
for($i=0; $i < count($owner); $i++) {
echo $owner[$i];
}

Thanks! -Nick
Jul 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Nick wrote:
Process page********************************************** ************
for($i=0; $i < count($owner); $i++) {
echo $owner[$i];
}

Thanks! -Nick


replace echo $owner[$i];

with

echo $_GET["owner"][$i];

- Marcus
Jul 16 '05 #2

P: n/a
Nick wrote:
Can someone please tell me how to access elements from a multiple
selection list? From what ive read on other posts, this is correct. I
keep getting an "Undefined variable" error though...

Form page********************************************** **************
<form action="/process.php" method="get" name="formOne" id="formOne">
<select name="owner[]" size="6" multiple id="owner[]">
<option value="one">one</option>
<option value="two">two</option>
<option value="three">three</option>
</select>
<input type="submit" name="Submit" value="Submit">
</form> Process page********************************************** ************
for($i=0; $i < count($owner); $i++) {
echo $owner[$i];
}


Just a hunch... Have you defined the variable $owner? If not, you are
probably depending on register_globals to being "on", which it may not
be in your system. Try using the following:
$owner = $_GET["owner"];
before your for... loop.

HTH
--
Marius

Jul 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.