Jump to content

PHP Optimization: mysql_fetch_assoc vs foreach


pcmansf

Recommended Posts

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.

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.