php mysqli fetch all

Solutions on MaxInterview for php mysqli fetch all by the best coders in the world

showing results for - "php mysqli fetch all"
Shana
30 Mar 2020
1$mysqli = new mysqli("host", "user", "password", "database", 'port', 'socket');
2
3$result = $mysqli->query("SELECT Name, Type, Color FROM Fruit");
4
5/**
6 * This optional parameter is a constant indicating what type of array should
7 * be produced from the current row data. The possible values for this parameter
8 * are the constants MYSQLI_ASSOC, MYSQLI_NUM, or MYSQLI_BOTH.
9 */
10$rows = $result->fetch_all(MYSQLI_ASSOC);
11
12foreach ($rows as $row) {
13  printf("%s - %s - %s\n", $row["Name"], $row["Type"], $row["Color"]);
14}