pcmansf Posted December 8, 2010 Share Posted December 8, 2010 Thank you for looking into this! I need to use result from mysql query twice or more on a page Should I do this: $sql = mysql_query("SQL"); while ($row = mysql_fetch_assoc($sql)) CODE ... while ($row = mysql_fetch_assoc($sql)) CODE2 OR should I keep result of a query in an array and use FOREACH instead? My concern is performance. Link to comment https://forums.phpfreaks.com/topic/221002-php-optimization-mysql_fetch_assoc-vs-foreach/ Share on other sites More sharing options...
bh Posted December 8, 2010 Share Posted December 8, 2010 If you want to stay a simple solution an array is a good choice. Another simple solution is mysqli with prepared statements. Link to comment https://forums.phpfreaks.com/topic/221002-php-optimization-mysql_fetch_assoc-vs-foreach/#findComment-1144361 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.