Click to See Complete Forum and Search --> : MySQL Query returning double nested array


Phill Pafford
07-31-2008, 02:57 PM
Hi All.

Need some help


$q = "SELECT * FROM " . DEFINED_TBL;

$result = mysql_query($q, $this->connection);

while($row = mysql_fetch_row($result))
{
$rs[] = $row;
}

return $rs;


results



foreach($result as $k1 => $d1)
{
echo "Key1: " . $k1 . " DATA1: " . $d1 . "<br />";
// This shows array as one of the values

foreach($d1 as $k => $d)
{
echo "Key: " . $k . " DATA: " . $d . "<br />";
// this has the values I want
}
}


returns look like this

Key1: 0 DATA1: Array
Key: 0 DATA: 1
Key: 1 DATA: WANTED RESULTS
Key: 2 DATA: 0

would like it to be returned in one array

bokeh
07-31-2008, 03:43 PM
How can you have it as one array? Each $row returns an array and your script is saving each of those arrays into a multidimensional array.