W3docs

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.

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:

Example of getting an array of rows with mysqli result

<?php

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

<div class="alert alert-info flex not-prose"> Watch a course <span class="hidden md:block">Watch a video course </span> Learn object oriented PHP</div>

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.