How can PHP be used to store data from a recordset into a variable?

To store data from a recordset into a variable in PHP, you can loop through the recordset using a while loop and assign each row's data to a variable. This allows you to access and manipulate the data as needed.

// Assuming $result is the recordset obtained from a database query

$data = array(); // Initialize an array to store the data

while ($row = mysqli_fetch_assoc($result)) {
    $data[] = $row; // Store each row's data in the array
}

// Now $data contains all the data from the recordset