jwilson122 Posted October 19, 2010 Share Posted October 19, 2010 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 More sharing options...
litebearer Posted October 19, 2010 Share Posted October 19, 2010 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 More sharing options...
jwilson122 Posted October 19, 2010 Author Share Posted October 19, 2010 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 More sharing options...
litebearer Posted October 19, 2010 Share Posted October 19, 2010 I prefer mysql_fetch_array as in my limited usage, I always know the names of my fields. Makes it easier for me. Link to comment https://forums.phpfreaks.com/topic/216292-fetch-data/#findComment-1124055 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.