Page to Page lag

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!

Moderator: General Moderators

Post Reply
HG-Bloodmorphed
Forum Newbie
Posts: 2
Joined: Thu Oct 27, 2011 11:32 am

Page to Page lag

Post by HG-Bloodmorphed »

Well I'm using a FREE ladder script however I edited to how I like it and I'm having problems with this lag issue.

To better understand go to: http://hellsguardians.com/ladder

If you navigate somewhere it wont lage, the only problem with this (that i know of) is clicking on players name and try navigating to somewhere else it have a freeze to it. It'll load for 2-5 minutes before going to where you navigated.

Heres the contents of the file:

http://pastebin.com/7iVJ8vxY


I've looked several times to see where this might be happening. I just cant quite figure it out
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Page to Page lag

Post by Celauran »

What's going on here? Why can't you use the player's name in the query rather than having to loop through a potentially huge array?

Code: Select all

// Get My Ladder Rank
$result = mysql_query($standingsSqlWithRestrictions." LIMIT ".$playersshown,$db) ;
 
// Loop through and find me
$cur = 1;
$rank = "";
while ($player = mysql_fetch_array($result)) {
    if ($player['name'] == $_GET['name']) {
        $rank = $cur;
        break;
    }
    $cur++;
}
You've got basically the same query four times. Clean this up.

Code: Select all

// Get the players elo hiscore
 
$sql = "SELECT winner, winner_elo FROM $gamestable WHERE winner = '$_GET[name]' AND contested_by_loser = '0' AND withdrawn ='0' ORDER BY winner_elo DESC LIMIT 0,1";
$result = mysql_query($sql, $db);
$row = mysql_fetch_array($result);
 
$hiscore_elo = $row['winner_elo'];
 
// Get the players elo loscore
 
$sql = "SELECT loser, loser_elo FROM $gamestable WHERE loser = '$_GET[name]' AND contested_by_loser = '0' AND withdrawn ='0' ORDER BY loser_elo ASC LIMIT 0,1";
$result = mysql_query($sql, $db);
$row = mysql_fetch_array($result);
 
$loscore_elo = $row['loser_elo'];
 
 
 
 
// Get the players best streak
$sql = "SELECT winner, winner_streak FROM $gamestable WHERE winner = '$_GET[name]' AND contested_by_loser = '0' AND withdrawn ='0' ORDER BY winner_streak DESC LIMIT 0,1";
$result = mysql_query($sql, $db);
$row = mysql_fetch_array($result);
$hiscore_streak = $row['winner_streak'];
 
// Get the players worst streak
$sql = "SELECT loser, loser_streak FROM $gamestable WHERE loser = '$_GET[name]' AND contested_by_loser = '0' AND withdrawn ='0' ORDER BY loser_streak ASC LIMIT 0,1";
$result = mysql_query($sql, $db);
$row = mysql_fetch_array($result);
$loscore_streak = $row['loser_streak'];
HG-Bloodmorphed
Forum Newbie
Posts: 2
Joined: Thu Oct 27, 2011 11:32 am

Re: Page to Page lag

Post by HG-Bloodmorphed »

Well, I'm not thinking that is the cause of this, as the demo I looked at before actually installing this is the EXACT same script i have now and it didnt do it. But I'm not sure how to merge those 4 in to one and I'm not sure what you mean on the first code.

I did not make this script so asking me how it works is beyond my knowledge. Thats the ONLY play is does this at and I believe many files use those 4 queries and don't do that.
Post Reply