PHP Associative Array gets Overwritten

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
beck030
Forum Newbie
Posts: 1
Joined: Mon May 04, 2009 4:10 pm

PHP Associative Array gets Overwritten

Post 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;
    }
}
 
Last edited by Benjamin on Mon May 04, 2009 5:46 pm, edited 1 time in total.
Reason: Changed code type from text to php.
Post Reply