• PHP Video Tutorials

PHP - Function MySQLi Fetch All



Syntax

mysqli_fetch_all(result,resulttype);

Definition and Usage

It is used to fetchs all result rows and returns the result set as an associative array

Return Values

It returns an associative array holding the result row.

Parameters

Sr.No Parameters & Description
1

result

It specifies the result set identifier

2

resulttype

It specifies what type of array that should be produced

Example

Try out the following example

<?php
   $connection_mysql = mysqli_connect("localhost","user","pass","db");
   
   if (mysqli_connect_errno($connection_mysql)){
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
   }
   
   $sql = "SELECT name FROM emp";
   $result = mysqli_query($connection_mysql,$sql);
   
   mysqli_fetch_all($result,MYSQLI_ASSOC);
   mysqli_free_result($result);
   mysqli_close($connection_mysql);
?>
php_function_reference.htm
Advertisements