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! Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.