PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Dang I see this again and again... Why do you use all these if's?!? Why do you need to check all the cases after one case has already matched?
Use if and elseif control structures instead. If you want it to be even faster then use the switch structure.
I've read that it is a little bit faster than if and elseif control structures (most of the time).
Yea okay, lol, this code was written half a year ago when i started coding.. Anyways, just changed it to switch structure, but it's still rather slow - And takes a good amount of server resources, I think. So is there a faster way than to make it loop through all rows? All I need it to do is count the amount of each rank...
$result_this = doquery("SELECT rankID FROM users WHERE village = '$user[village]' AND rankID = 1");
$academy = mysql_num_rows($result_this);
And then do the same with each one of the other ranks.
Note: this is just a suggestion and I really don't know whether it's faster or not! it might be even slower so just try doing it like this and to see if it is faster. If it is - cool, use it! If it isn't, then don't use it
If you've got thousands of rows, I might suggest adding some redundancy and creating a `village` table that has the counts for each of the types of ninja.