Re: arrays

From: Date: Mon, 10 Jul 2006 20:10:59 +0000
Subject: Re: arrays
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-239277@lists.php.net to get a copy of this message
Both work great. Thanks On 7/10/06, Brad Bonkoski <bbonkoski@mediaguide.com> wrote:
When loading the array you will only ever get the last record returned... so count($oarray) will always be 1? Perhaps something like this: Function.... $sql = "..."; $ret = array(); while($row = mysql_feth_array($reault)) { array_push($ret, $row); } return $ret; then... $data = function(); $c = count($data); for($i=0; $i<$c; $i++) { $row = $data[$i]; print_r($row); } Should give you what you want... As for your "orderly" fashion, I would put this load on the database, and not really PHP... if you want to make it associate you can...just push the assocative onto another array so you get the complete set... -B Dallas Cahker wrote: Banging my head against a wall with arrays, maybe someone can help me with the answer. I have a db query that returns results from 1-100 or more. I want to put the results into an array and pull them out elsewhere. I want them to be pulled out in an orderly and expected fashion. part of function $sql="Select * FROM blah Where blahid='1'"; run sql while ($row=mysql_fetch_array($result)) { $oarray=array('blah1' => $row['lah1'], 'blah2' => $row['lah2'], 'blah3' => $row['lah3']); } return $oarray part of display $OLength=count($oarray); for ($i = 0; $i < $OLength; $i++){ echo "O1 : ".$oarray['blah1'][$i]."<br>"; echo "O2 : ".$oarray['blah2'][$i]."<br>"; echo "O3 : ".$oarray['blah3'][$i]."<br>"; } this gets me nothing, and I am unsure where I am going wrong, other then all over the place.


« previous php.general (#239277) next »