Mysqli fetch assoc or Return mysqli_fetch_assoc - PHP MySQL Display

mysqli_fetch_assoc / Mysqli Fetch Assoc

PHP 6 Months 100% Job Assistance Program. for more info... call on 8588829328

Fetch data using mysqli_fetch_assoc( ) function

mysqli_fetch_assoc() return the rows from the number of records available in the database as an associative array.

at a time it return only the first row as an associative array. if we want to retrieve all the records of the table then we must put this function inside the while loop.

Syntax

Display the records using mysqli_fetch_assoc( )

In the above example first connection to the database is created after that the result provided by mysqli_query() is passed to mysqli_fetch_assoc() and the data of the associative array is displayed .

Display all records from empInfo table using mysqli_fetch_assoc( ) function.

Output :

Emp_id Name Email Mobile
1 devesh devesh@gmail.com 9910099100
2 deepak deepak@gmail.com 9210053520
3 ravi ravi@gmail.com 9810098100

In the above example first connection to the database is created after that the result provided by mysqli_query() is passed to mysqli_fetch_assoc() and array returned is stored in ‘r’ variable and it put in while loop to fetch all records . after that the data is displayed in tabular form.

Related Topic

mysqli_fetch_array

mysqli_fetch_row

Latest Trending Technologies