查询内部while循环只显示1个结果

i'm making a while loop in php and it all goes well but the problem is that I don't only want to get the id of the user but also some other stuff that is inside another table, so when I go ahead and make a query inside this while loop and select everything from that second table (where the id is equal to the id of the result from the first query), it only returns 1 result...

So this is the code that I currently have:

public function getFriends($id)
{
global $params;

$get = $this->db->select("{$this->DB['data']['friends']['tbl']}", "*",
                          array(
                                "{$this->DB['data']['friends']['one']}" => $id
                          )
                        );

if($get)
{
    while($key = $get->fetch())
    {
        $query = $this->db->query("SELECT * FROM {$this->DB['data']['users']['tbl']}
                                   WHERE {$this->DB['data']['users']['id']} = :id",
                                   array(
                                         "id" => $key->{$this->DB['data']['friends']['two']}
                                   )
                                 );

        while($row = $query->fetch())
        {
            $params["user_friends"][] = [
                "id"   => $key->{$this->DB['data']['friends']['two']},
                "name" => $row->{$this->DB['data']['users']['username']},
                "look" => $row->{$this->DB['data']['users']['figure']}
            ];
        }
    }
}
else
{
    $params["update_error"] = $params["lang_no_friends"];
}
}

Thanks in advance! Please help me out!

In the absence of answers, I don't know what db framework you are using behind the scenese...PDO, mysqli_, or (hopefully not) mysql_. But, in any case, the problem might be that your second query stops the first from continuing. I would use PDO->fetchAll() to get them all...but you say you can't do that...so, looping the first and loading those results into an array is the first thing I would do to see if this is the problem:

public function getFriends($id)
{
    global $params;

    $get = $this->db->select("{$this->DB['data']['friends']['tbl']}", "*",
                              array(
                                    "{$this->DB['data']['friends']['one']}" => $id
                              )
                            );

    $firstResults = array();
    if( $get ) {
        while( $key = $get->fetch() ) {
            $firstResults[] = $key;
        }
    }
    else
    {
        $params["update_error"] = $params["lang_no_friends"];
    }

    foreach( $firstResults AS $key )
    {
        $query = $this->db->query("SELECT * FROM {$this->DB['data']['users']['tbl']}
                                   WHERE {$this->DB['data']['users']['id']} = :id",
                                   array(
                                         "id" => $key->{$this->DB['data']['friends']['two']}
                                   )
                                 );

        while($row = $query->fetch())
        {
            $params["user_friends"][] = [
                "id"   => $key->{$this->DB['data']['friends']['two']},
                "name" => $row->{$this->DB['data']['users']['username']},
                "look" => $row->{$this->DB['data']['users']['figure']}
            ];
        }
    }
}

If this doesn't work, then we need more data...e.g. what is the query generated? When you run it manually does it return more than one result? If you get rid of the inner-query, does this fix it? etc.

The first step when diagnosing PHP and Mysql issues is to add lines to your code that tell you what each line is doing (declare each time a loop is entered; when each mysql query is run, spit out the query string) so you can narrow down where the problem is. Often this makes you feel stupid in retrospect: "Duh, this query didn't return anything because I formatted the record ID wrong" and so forth.

The code snippet you've provided above isn't super helpful to me. I'm a troubleshooter (not a parser) so I need diagnostic data (not straight code) to be of any more help than this.