Re: Multidimentional array problems

From: Date: Mon, 03 Apr 2006 22:49:27 +0000
Subject: Re: Multidimentional array problems
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-233163@lists.php.net to get a copy of this message
I am trying to read form a database and place everything in a multi-dimentional array This is what I am doing and the output (for testing) seems correct while($row=mysql_fetch_array($result)) { $banner= array($arrayIndex => $row); echo $banner[$arrayIndex]["image"]. "<br>"; echo $banner[$arrayIndex]["url"]. "<br>"; echo $banner[$arrayIndex]["display_type"]. "<br>"; $arrayIndex++; }
What are you setting $arrayIndex to initially (before the while loop starts?)
When I try and use $value=0; while($value < $number_of_banners_db ) { echo $banner[$value]["url"]. "<br>"; echo $banner[$value]["image"]. "<br>"; echo $banner[$value]["display_type"]. "<br>"; } I only get the last set of values that where entered into the array. I want to be able to pull all the values out $banner[0]['url'] $banner[1]['url'] $banner[2]['url'] etc. I don't use arrays much and I have been going thru my books but I still can't seem to get it to work.
Try a print_r($banner) and see what it looks like.... -philip

« previous php.general (#233163) next »