Try unset($myrow_it).

You don't want to reset the array, you want to clear it, then use a new
array (with the same name, and the same $result) for another while loop.

FWIW, I'm pretty sure I'd just use three distinct queries.  Infact, it'd be
worth you timing your scripts with both these versions to see what works out
quicker -- three queries, or lots of if() statements [remember, you're in a
while loop, so 5000 rows * 3 if statements = 15000!!]

Put this at the top:

<?
$show_timer = 1;
function getmicrotime()
    { 
    list($usec, $sec) = explode(" ",microtime());
    return ((float)$usec + (float)$sec);
    } 
$time_start = getmicrotime();
?>

And this at the end:

<?
if($show_timer)
    {
    $time_end = getmicrotime();
    $timer = $time_end - $time_start;
    echo "Timer: {$timer}<BR>";
    }
?>

Run the script with both versions about 10 times each, and take the average
:)


There are many many ways I can see that you could clean up and optimise the
script you've shown (not intended as an insult AT ALL!) -- quite possibly
some of these would make more of a difference to your performance than
limiting yourself to just one query... at the very least, it would make
updating the script easier, and reduce the lines of code.


Good luck,

Justin French



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to