I have been warned by many to always avoid any 'loop' commands. The script may not be able to keep up of the computer is older and maybe slow. The script will try and read, and not kep up and the actual PC will crash.
Again this is just an 'opinion' ans subject to bashing. ( though it can be "Googled" ).

*Attempts to Bash Wiley*

No seriously, Im not trying to bash. Thinking about this issue I can't agree. Granted I haven't tested, BUT!!!
If I ask mirc to perform a while loop.
While (%x) {
if ($hget(table,%x)) { msg $chan Yayy!! }
dec %x
}
My computer is going to handle it as fast as it can. If I have a slow computer, then it will just be slower to go through this while loop. I don't see how it would miss anything.
Im looking at it on a step by step basis.
step 1: evaluate while and variable
step 2: variable = 5, evaulate comparison, run command if matches
step 3:dec %x, evaluate while loop. if %x > 0? if so continue, if not halt.
step4: evaluate comparison, run command if matches
step5:dec %x, evaluate while loop
step 6: evaluate comparison, run command if matches
step 7: dec %x evaluate while loop
etc.
See, mIRC is going to go through these steps one at a time. If your computer is slow, it is still going to go through each step, just slower. This is my opinion just going over the idea "logically".
"while (%x > 0)"
Yes David is correct, this would probably be more stable.
If the %x == 0, then !%x is true.
(This is why it may be best to say if (%x == $null) if dealing with numbers in the variable. Since !5x will be true if %x == 0)
I just wanted to be clear about using the while loop as such. Both ways are correct. David's suggestion would technically be more stable but not neccesary and I don't see that it would fix your issue with flooding out.
If you really want to whois everyone in the room with a while loop use timers. It gets a little tricky though. You may want to use a queu code like the ss alias David and Petertje provide.
The issue is if I set a 1 second timer on every pass through the while loop, it will still perform the command just as fast, only a second later. Instead I have had to add a little bit of time every time it passes through.
Example:
%x = 5 /timer 1 1 /command (waits one second)
%x = 4 wait 1 second
%x = 3 wait 1 second
%x = 2 wait 1 second
These command will execute just as fast, only one second after.
So I need to make the timers different. This way here will execute the commands once every 500 ms.
%x = 5 wait 1 second before command
%x = 4 wait 1.5 seconds before command
%x = 3 wait 2 seconds before command
%x = 2 wait 2.5 seconds before command
%x = 1 wait 3 seconds before command
This way it actually spaces the commands out.
( I typically just use the ss alias!! Thanks David and Petertje!)