You are here: accessing values from an array « PHP Programming Language « IT news, forums, messages
accessing values from an array

Posted by mtjarrett on 11/18/05 04:37

i having trouble accessing the values from superglobal arrays. there
are two situations but i'm pretty sure it's the same problem.

here's the deal:

on page1.php i have several check boxes. before listing them i have
the code
$info = array();

and then each checkbox has

<input type="checkbox" name="info[]" value="Red">Red<br>
<input type="checkbox" name="info[]" value="Blue">Blue<br> ...and so
on

the form posts to the same page, then checks the info and cleans it up
if needed. then it sets it to a session variable like so:

if (isset($_POST['submitted'])){

$errors = array();

if(!empty($_POST['info'])){
$_SESSION['info'] = escape_data($_POST['info']);} else {
$errors = 'bad';}
}

then it directs you to the next page, page2.php.

on page2.php, i can't figure out how to access the array. i want to
print each element of the array on a seperate line. w/o all the other
it would look something like:

echo "$info[1]<br>";
echo "$info[2]<br>";

i'd like to do this with a foreach loop but i can't even access one
variable. not sure where to go from here.

NOTE: when i was doing it earlier and passing the information from page
to page with the post method and then finally sending myself an email
with all the array infromation imploded into a string, it worked fine.

thanks for your time and knowledge.
-michael

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация