mysqli_fetch_assoc() | Fetch Multiple Rows in PHP | Example

The simplest way to Fetch Multiple Rows in PHP example looks like this.

<?php

$conn = mysqli_connect("localhost", "username", "password", "database-name");

$query = mysqli_query($conn, "SELECT * FROM table-name");

$row = mysqli_fetch_assoc($query);

print_r($row);

?> 

In this section, fetch single rows from the database. In the above, the first query to relate connectivity database and another one mysqli_query() this function for run query along with the condition. Thus, the mysqli_fetch_assoc() function use retrieve data from the data then store a variable.

mysqli_fetch_assoc() – How to Fetch Multiple Rown From the Database in PHP

<?php
$conn = mysqli_connect("localhost", "username", "password", "database-name");

$query = mysqli_query($conn, "SELECT * FROM student_table");
     while ($row = mysqli_fetch_assoc($query)) {     
		
      print_r($row);   
      
}
?>   

In this section, you can fetch multiple rows from the database in PHP. Also, this code using a while loop to retrieve data. Therefore, whenever get data to apply this mysqli_fetch_assoc() with a while loop. How to Store and Retrieve Image from database in Php

Hence, Keep scrolling down for the next chapter.

[wlearnsmart]

4 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts

Related Post

mysqli_real_escape_string() | MYSQLi Escape String | PHP Example

The simplest way to use the MYSQLi Escape String example looks like this. In this mysqli_real_escape_string() function allow two-parameter which is a database connection and the other one passes a string. Accordingly, PHP should be used while insert data in the table. Hence, Keep scrolling down for the next chapter. Facebook Linkedin Tweet

Read more

mysqli_num_rows() | Check if ResultSet is empty | Example

The simplest way to use check if resultset is empty example looks like this. Here, the mysqli_num_rows() function returns the number of rows in the database table in the result set. Accordantly, you have to apply to check how many rows are available. Above all, show this type of example to check MySQLi num rows […]

Read more

x