Which is the best method to fetch the data from mysql?
1.mysql_fetch_array()
2.mysql_fetch_object()
3.mysql_fetch_row()
4.mysql_fetch_assoc()

Answer Posted / mervin thomas

I think all mysql_fetch_array() is the best one, since we
can get the value of the records using the numeric index (as
numbers) or using the string index (as column).
mysql_fetch_array () => fetches the records using the two
way index method,
(ex). $record[0];
$record['id'];
gives the same value.

mysql_fetch_row() fetches the records using the numerical index
ex. $record[0];

mysql_fetch_assoc() fetches the records using the string
index and returs the records as associative array
ex. $record['id'];

mysql_fetch_object() fetches the records as the object.
ex. $record->id;

Is This Answer Correct ?    13 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the current stable version of php? What advance thing in php7?

739


Tell me what is the importance of "action" attribute in a html form?

761


What is the use of preg_match in php?

741


Which is the correct way to check if a session has already been started ?

761


What is the function of string in c?

768


Maine 12th ke bad 2 years ka web designing ka course kiya hai. Php me achcha hu. Ek fresher ko is field me kitna mil sakta hai ?

5000


What is url encoding and decoding in php?

800


How long will it take to learn php?

708


How to convert a string to uppercase in php?

737


How to return ascii value of character in php?

781


What is csrf mvc?

746


What is form action php?

783


What are the different opening and closing tags available in PHP?

783


How to generate a form?

827


What is the difference between include and require?

739