从具有特定ID的db中检索所有帖子

I'm want to retrieve all posts with a certain listId from the database, but only retrieves the last one. Below is the code, what am I doing wrong?

from listModel.php:

public function GetListElements($listId) {

    $query = "SELECT le.listElemId, le.listElemName, le.listElemOrderPlace, led.listElemDesc
                FROM listElement AS le
                INNER JOIN listElemDesc as led
                ON le.listElemId = led.listElemId
                WHERE le.listId=?";

    $stmt = $this->m_db->Prepare($query);

    $stmt->bind_param("i", $listId);

    $listElements = $this->m_db->GetListElements($stmt);

    return $listElements;
}

from database.php:

public function GetListElements(\mysqli_stmt $stmt) {

    if ($stmt === FALSE) {
            throw new \Exception($this->mysqli->error);
    }

    //execute the statement
    if ($stmt->execute() == FALSE) {
            throw new \Exception($this->mysqli->error);
    }

    //Bind the $ret parameter so when we call fetch it gets its value
    if ($stmt->bind_result($listElemId, $listElemName, $listElemOrderPlace, $listElemDesc) == FALSE) {
        throw new \Exception($this->mysqli->error);
    }

    // Hämtar ids och användarnamn och lägger i arrayen.
    while ($stmt->fetch()) {
        $listElements = array('listElemId' => $listElemId,
                             'listElemName' => $listElemName,
                             'listElemOrderPlace' => $listElemOrderPlace,
                             'listElemDesc' => $listElemDesc);
    }

    $stmt->Close();

    return $listElements;    // contains only the last post in the table
}

The tables

listElement: listElemId, listElemName, listId, listElemDescId, listElemOrderPlace

listElemDesc: listElemDescId, listElemId, listElemDesc

You are overwriting $listElements variable on each iteration, to fix it you can use an array variable:

$listElements = array();
while ($stmt->fetch()) {
    $listElements[] = array('listElemId' => $listElemId,     //notice brackets: []
                         'listElemName' => $listElemName,
                         'listElemOrderPlace' => $listElemOrderPlace,
                         'listElemDesc' => $listElemDesc);