Difference between MYSQL_ASSOC,MYSQL_NUM and MYSQL_BOTH ?

Answer Posted / avanthi g

Fetch a result row as an associative array, a numeric array, or both
Returns an array that corresponds to the fetched row and moves the internal data pointer ahead.

Example:
MYSQL_NUM returns a numerically indexed array.
$row = mysql_fetch_array($result, MYSQL_NUM);
echo $row[0];

MYSQL_ASSOC returns an associative array.
$row = mysql_fetch_array($result, MYSQL_ASSOC);
echo $row["student_id"];

MYSQL_BOTH returns both.
$row = mysql_fetch_array($result, MYSQL_BOTH)
echo $row[0]." ".$row["name"];

Is This Answer Correct ?    46 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

can you elaborate on blob and text in mysql? : Mysql dba

470


How to get a list of all tables in a database?

570


what is a cursor? : Mysql dba

481


How to enter boolean values in sql statements?

537


Write a query to find duplicate rows in table?

488






What is mysql and why it is used?

554


What is truncate command?

453


Tell us something about heap tables?

545


How do I start mysql server?

465


How do I connect to a database in mysql workbench?

542


What is pdo :: fetch_assoc?

491


What are queries used for?

498


In mysql, what is the default storage engine?

501


Can you tell which of the following where clauses is faster?

440


Explain what is mysql?

577