Display data using mysql_fetch_array( ) function

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

at a time it return only the first row as an associative array or numeric 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 whose email is devesh@gmail.com using mysql_fetch_array()

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

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

In the above example first connection to the database is created after that the result provided by mysql_query() is passed to mysql_fetch_array() 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.



  • ankush. sharma

    hello sir, can we use count function instead of mysqli_num_rows?

    • Yes we can ankush

      • ankush. sharma

        ok sir
        thank you sir