Jump to content

Difference between mysql_fetch_array and mysql_query


eldan88

Recommended Posts

You use mysql_query to perform the query itself. This function returns a resource that you iterate upon to extract the contents of the result of the query with various fetch functions, including the on you mentioned.

mysql_query sends a query to the database and returns the results.

 

mysql_fetch_array is used on the results from the mysql_query to fetch a row from the results in the form of an array

 

simple example that would print a list of all first/last names in the users table

 

$result = mysql_query("SELECT firstName, lastName FROM users");

while($row = mysql_fetch_array($result)){

  echo $row['firstName'] ." ". $row['lastName'] ."<br/>";

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.