What is the issue with the code that is causing only the first record to be displayed in the array?

The issue is that the `return` statement inside the `foreach` loop is causing the loop to terminate after processing the first record, resulting in only the first record being displayed in the array. To fix this issue, we should store each record in a temporary array inside the loop and then return the array containing all records after the loop has completed.

function getRecords() {
    $records = array();
    
    // Fetch records from database
    $result = $db->query("SELECT * FROM records");
    
    // Process each record
    while($row = $result->fetch_assoc()) {
        $records[] = $row;
    }
    
    return $records;
}