get array of rows with mysqli result

You can use the mysqli_fetch_assoc() function to retrieve an associative array of a single row from a result set, and use a loop to iterate through the result set and store each row in an array. Here's an example of how you could do this:


$result = mysqli_query($conn, "SELECT * FROM table_name");
$rows = [];
while ($row = mysqli_fetch_assoc($result)) {
  $rows[] = $row;

Watch a course Learn object oriented PHP

In this example, $conn is the connection to the database, and $result is the result set returned by the query. The mysqli_fetch_assoc() function is called in a loop until there are no more rows in the result set, and each row is added to the $rows array.