Hello Coders, here are not a very new topic for the experienced people but a very interesting topic for beginners who are always confused with these function as I mention on heading.

Today I elaborate all these with some small examples, I think you all understand very well after reading that one time. So let’s start.

Here is a table for better understanding, Suppose this is MySQL table and there is one row.




This function as the name suggests giving rows of the data which we set in the query. But one thing the values will come in order as we define on the query and indexed start with 0 and end with less than a number of the selected column. 

Here is the example which shows you how this is implemented on the code.


This is the second PHP function which is also used for data fetching but with different format. This is also called the ASSOCIATIVE array format. Means on this array, all elements have their name with values. We fetch all value using their field name.

Like the following example,


All the above functions are using to fetch data from the database but with a different type. This function also does the same but fetches data from the database using Object type.

Please check the example below for a better understanding.


This function, fetch result from a database as an associative array, index numeric array and both numeric and associative at the same code.

See here on the example,

Above all are the difference between these functions, check if you have some improvements then please comment below.

To know more https://www.php.net/manual/en/ref.mysql.php

Also Check:

Happy Coding…!

Was this article helpful?

By Bikash

My name is Bikash Kr. Panda. I own and operate PHPCODER.TECH. I am a web Programmer by profession and working on more than 50 projects to date. Currently I am working on the web-based project and all the CMS and frameworks which are based on PHP.

One thought on “mysql_fetch_row() VS mysql_fetch_object() VS mysql_fetch_assoc() VS mysql_fetch_array()”

Leave a Reply

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