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 php addslashes?

763


How can we set and destroy the cookie in php?

681


What is interface? Why it is used?

729


Tell me how to get the value of current session id?

691


How to get the position of the character in a string in php?

830


What is "print" in php?

694


what is benefit of magento?

2251


What do you mean by core php?

689


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

726


What is get method in java?

716


What is a php tag?

698


How to get the total number of values in an array?

723


Write a php script to get the largest key in an array?

744


What is restful api?

708


What is a comment in php?

816