Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what is the difference between mysql_fetch_array() and
mysql_fetch_row()?

Answer Posted / deepaa

There is not so much difference between the
mysql_fetch_array and mysql_fetch_assoc in the sense that
both can fullfill your requirements but it depends on your
need and ease of use. I prefer mysql_fetch_array because
with it i can use both indexed value and associative value.

I will explain this difference with short example:
$sql = mysql_fetch_array(‘select name, address from
tbl_customer’);
It means that you are getting answer directly into an array
, and you dont need to know the field value of the elements
to be outputed.
Just print the output as:

foreach($sql as $ans){
echo $ans[0].' lives in '.$ans[1];
}
or
foreach($sql as $ans){
echo $ans['name'].' lives in '.$ans['address'];

}

mysql_fetch_assoc, you can output the result as $ans['name']
but not $ans[0] . What i want say is you need to know about
the field name of the table. Ok here is the sample code:

foreach($sql as $ans){
echo $ans['name'].' lives in '.$ans['address'];
}
But not
foreach($sql as $ans){
echo $ans[0].' lives in '.$ans[1];

}

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does $globals mean?

921


What is the use of trim in php?

936


Explain me differences between get and post methods?

963


What are the 3 types of sessions?

1000


How to write the form tag correctly for uploading files?

922


What is composer phar?

938


How to invoke a user function?

938


What is PHP? Who is the father or inventor of PHP?

1000


Write a program to get second highest number in an array using php?

961


What are the differences between session and cookie?

961


What is repository in php?

964


How to strip whitespace (or other characters) from the beginning and end of a string?

844


Tell me how can we determine whether a variable is set?

877


What is urlencode and urldecode in php?

1061


What is a php session?

1013