Page 1 of 1

PHP Associative Array gets Overwritten

Posted: Mon May 04, 2009 4:32 pm
by beck030
hi, this is my first post here.. please excuse my english.

i want to fill an associative array with a loop. the datas come from a mysql-query.

the problem is, that the array keeps getting overwritten so the output only shows the last entry of the sql-query. i tried to put the array-pointer at the end of the array after the foreach-loop, but it didnt work. is there another way to avoid my array to get overwritten?

this is my code:

Code: Select all

    
public function set_seriallist()
{       
    while ($fetched = mysql_fetch_assoc($this->serial_result)) {
        foreach ($fetched as $key => $value) {
            $this->seriallist_array[$key] = $value;
    }
}