accessing data from an array within an array.
| From: | Adam Preece | Date: | Sat, 07 May 2011 15:36:52 +0000 |
| Subject: | accessing data from an array within an array. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-312715@lists.php.net to get a copy of this message | ||
hello all.
im trying to make a function that fetches all rows in the database and stores each row (Array)
within an array.
so the code is as follows:
public function fetch_all($table_name,$order = "DESC"){
$array['row'] = array();
strtoupper($order);
$query = "SELECT * FROM
{$table_name} ORDER BY id {$order}";
$result = $this->gen_query($query);
while($row = $this->fetch_assoc($result)){
$array['row'][] = $row;
}
if($this->sql_error_check($result)){
return $array;
}
}
this returns (ill just paste 1 row for the sake of the email length:
Array ( [row] => Array ( [0] => Array ( [id] => 9 [name] => TESTER [title] => TESTER
[heading] => TESTER [text] =>
TESTER
[gallery_id] => 0 [meta_desc] =>
TESTER
[meta_keywords] => TESTER [meta_author] =>
TESTER
[page_id] => 0 [date_time] => 2011-05-07 06:49:39 [image] => [user_access_id] => 1 )
How do i access each array within the array and throw out the data for each one.
im pretty confused on this one.
any help would be appreciated.
Adam