Jump to content

[SOLVED] While loop takes too long to run...


The Little Guy

Recommended Posts

I have the following code, it takes forever to run. I have tested it on ~ 400+ returned results from the database.

 

 

What part of this is making it take so long?

 

	while($row = mysql_fetch_array($sql)){
		list($dat,$time) = explode(" ",$row['date']);

		/* Generate Stats For Today */
		if($dat == date("Y-m-d"))
			$totalToday++;
		if($dat == date("Y-m-d") && !in_array($row['ip'],$ipArrayToday)){
			$totalTodayUnique++;
			array_push($ipArrayToday,$row['ip']);
		}

		/* Generate Yesterday's Stats */
		if($dat == date("Y-m-d",strtotime('-1 day')))
			$totalYesterDay++;
		if($dat == date("Y-m-d",strtotime('-1 day')) && !in_array($row['ip'],$ipArrayYesterDay)){
			$totalYesterDayUnique++;
			array_push($ipArrayYesterDay,$row['ip']);
		}
	}

Link to comment
https://forums.phpfreaks.com/topic/123990-solved-while-loop-takes-too-long-to-run/
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.