Jump to content

fetch data


jwilson122

Recommended Posts

Okay so, I have always been curious, just never have taken the time to ask someone / learn what the differences are in fetches. What does mysql_fetch_array and mysql_fetch_row do thats different from each other? When pulling data from the database, would I like fetch array, or fetch row? or even fetch assoc? Thanks!

Link to comment
https://forums.phpfreaks.com/topic/216292-fetch-data/
Share on other sites

The mysql_fetch_row() function returns a row from a recordset as a numeric array.

 

The mysql_fetch_array() function returns a row from a recordset as an associative array and/or a numeric array.

 

The mysql_fetch_assoc() function returns a row from a recordset as an associative array.

 

This function gets a row from the mysql_query() function and returns an array on success, or FALSE on failure or when there are no more rows.

 

Link to comment
https://forums.phpfreaks.com/topic/216292-fetch-data/#findComment-1124044
Share on other sites

The mysql_fetch_row() function returns a row from a recordset as a numeric array.

 

The mysql_fetch_array() function returns a row from a recordset as an associative array and/or a numeric array.

 

The mysql_fetch_assoc() function returns a row from a recordset as an associative array.

 

This function gets a row from the mysql_query() function and returns an array on success, or FALSE on failure or when there are no more rows.

 

Okay cool thanks. So which should I use when I pull information from the database just to store in variables and echo out? And, which one should I use for a while loop?

Link to comment
https://forums.phpfreaks.com/topic/216292-fetch-data/#findComment-1124049
Share on other sites

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.