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']);
The above line will not add an array element per row. Change $oarray= to
$oarray[]=
}
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 is not the way the array is arranged. Switch your indices around so
it's like so...
echo "O1 : ".$oarray[$i]['blah1']."<br>";
echo "O2 : ".$oarray[$i]['blah2']."<br>";
echo "O3 : ".$oarray[$i]['blah3']."<br>";
this gets me nothing, and I am unsure where I am going wrong, other then
all
over the place.
-Stut
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php