Stacking rows from a database in an array
Posted: Tue Sep 09, 2008 5:51 am
Hi,
I want to be able to stack rows returned from a database query in an array which I can then pass to another file for display.
Here's a sample code of how am trying to achieve this, but it's obviously not working.
by the way am using PDO objects to retrieve the rows.
------------------------------------------------
while($row = $this->obj_db_cnx->safe_fetch_array()) {
$this->ary_result['users'] = $row;
}
------------------------------------------------------
But the when I pass the ary_result['users'] as a parameter to another file, only the last row is displayed.
Please advice.
Thanks.
I want to be able to stack rows returned from a database query in an array which I can then pass to another file for display.
Here's a sample code of how am trying to achieve this, but it's obviously not working.
by the way am using PDO objects to retrieve the rows.
------------------------------------------------
while($row = $this->obj_db_cnx->safe_fetch_array()) {
$this->ary_result['users'] = $row;
}
------------------------------------------------------
But the when I pass the ary_result['users'] as a parameter to another file, only the last row is displayed.
Please advice.
Thanks.