Answers for "php mysqli fetch all"

PHP
0

php mysqli fetch all

$mysqli = new mysqli("host", "user", "password", "database", 'port', 'socket');

$result = $mysqli->query("SELECT Name, Type, Color FROM Fruit");

/**
 * This optional parameter is a constant indicating what type of array should
 * be produced from the current row data. The possible values for this parameter
 * are the constants MYSQLI_ASSOC, MYSQLI_NUM, or MYSQLI_BOTH.
 */
$rows = $result->fetch_all(MYSQLI_ASSOC);

foreach ($rows as $row) {
  printf("%s - %s - %s\n", $row["Name"], $row["Type"], $row["Color"]);
}
Posted by: Guest on August-26-2021

Browse Popular Code Answers by Language