7steij17 Posted October 16, 2007 Share Posted October 16, 2007 I'm new here so I am not sure if this is the right place... My host made me move to a dedicated server and I discovered that the only thing using so much CPU was this script: http://www.atarcade.com/test123.php <TR> <TD> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD> </TD></TR></TBODY></TABLE></TD></TR> <TR> <TD> <tr><td><table width="100%" border="0" cellpadding="0" cellspacing="0" class="categHead"> <tr><td> Top Flash Games </td> </tr></table></td></tr><tr><td><table width="100%" border="0" cellspacing="6" cellpadding="0"> <tr> <? $sql2 = "SELECT * FROM games Where category!='Classic Nintendo' AND category!='Video' AND category!='Other' AND category!='GBC' ORDER BY played DESC LIMIT 0,2"; $result2 = mysql_query($sql2); while($row2 = mysql_fetch_array($result2)) { ?> <td width="50%" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="3" class="game"> <tbody> <tr align="left" valign="top"> <td align="center" width="33%"><span class="normalText"> <a href="play-flash-<? echo $row2["gameid"]; ?>.html"> <img src="http://files.atarcade.com/img/<? echo $row2["image"]; ?>" alt="<? echo $row2["name"]; ?>" border="0" height="60" width="60"></a></span></td> <td class="normalText"> <b> <a href="play-flash-<? echo $row2["gameid"]; ?>.html"> <? echo $row2["name"]; ?> </a></b><br> <?php $max_length = 55; if (strlen($row2['desc'])>$max_length) echo substr($row2['desc'], 0, strrpos(substr($row2['desc'], 0, $max_length), ' ')).'.'; else echo $row2["desc"]; ?> </td> </tr> </tbody> </table> </td> <? } ?> <? $sql2 = "SELECT * FROM games"; $result2 = mysql_query($sql2); $totalplayed = 0; while($row2 = mysql_fetch_array($result2)) { $totalplayed = $totalplayed+$row2["played"]; } ?> <tr> <? $sql2 = "SELECT * FROM games Where category!='Classic Nintendo' AND category!='Video' AND category!='Other' AND category!='GBC' ORDER BY played DESC LIMIT 2,2"; $result2 = mysql_query($sql2); while($row2 = mysql_fetch_array($result2)) { ?> <td width="50%" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="3" class="game"> <tbody> <tr align="left" valign="top"> <td align="center" width="33%"><span class="normalText"> <a href="play-flash-<? echo $row2["gameid"]; ?>.html"> <img src="http://files.atarcade.com/img/<? echo $row2["image"]; ?>" alt="<? echo $row2["name"]; ?>" border="0" height="60" width="60"></a></span></td> <td class="normalText"> <b> <a href="play-flash-<? echo $row2["gameid"]; ?>.html"> <? echo $row2["name"]; ?> </a></b><br> <?php $max_length = 55; if (strlen($row2['desc'])>$max_length) echo substr($row2['desc'], 0, strrpos(substr($row2['desc'], 0, $max_length), ' ')).'.'; else echo $row2["desc"]; ?> <br> </tr> </tbody> </table> </td> <? } ?> <? $sql2 = "SELECT * FROM games"; $result2 = mysql_query($sql2); $totalplayed = 0; while($row2 = mysql_fetch_array($result2)) { $totalplayed = $totalplayed+$row2["played"]; } ?> </tr> </table></td></tr><tr> <td><table width="100%" border="0" cellpadding="0" cellspacing="0" class="categFoot"> <tr><td><div align="right"> <a href="top-100-games.html" class="blackLink">View Top 100 Flash Games ...</a> </div></td></tr></table></td></tr></table></td></tr></table> does anyone know how I can optimize this to use less server resources, I want it to look the same but just use less resources, this code gets the job done but it uses so much CPU seconds. Any help would be grateful, I don't know how to combine the two parts into one so it displays the same. Thanks. Link to comment https://forums.phpfreaks.com/topic/73548-small-script-uses-to-much-cpu-seconds/ Share on other sites More sharing options...
7steij17 Posted October 16, 2007 Author Share Posted October 16, 2007 I'm new here so I am not sure if this is the right place... My host made me move to a dedicated server and I discovered that the only thing using so much CPU was this script: http://www.atarcade.com/test123.php <TR> <TD> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD> </TD></TR></TBODY></TABLE></TD></TR> <TR> <TD> <tr><td><table width="100%" border="0" cellpadding="0" cellspacing="0" class="categHead"> <tr><td> Top Flash Games </td> </tr></table></td></tr><tr><td><table width="100%" border="0" cellspacing="6" cellpadding="0"> <tr> <? $sql2 = "SELECT * FROM games Where category!='Classic Nintendo' AND category!='Video' AND category!='Other' AND category!='GBC' ORDER BY played DESC LIMIT 0,2"; $result2 = mysql_query($sql2); while($row2 = mysql_fetch_array($result2)) { ?> <td width="50%" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="3" class="game"> <tbody> <tr align="left" valign="top"> <td align="center" width="33%"><span class="normalText"> <a href="play-flash-<? echo $row2["gameid"]; ?>.html"> <img src="http://files.atarcade.com/img/<? echo $row2["image"]; ?>" alt="<? echo $row2["name"]; ?>" border="0" height="60" width="60"></a></span></td> <td class="normalText"> <b> <a href="play-flash-<? echo $row2["gameid"]; ?>.html"> <? echo $row2["name"]; ?> </a></b><br> <?php $max_length = 55; if (strlen($row2['desc'])>$max_length) echo substr($row2['desc'], 0, strrpos(substr($row2['desc'], 0, $max_length), ' ')).'.'; else echo $row2["desc"]; ?> </td> </tr> </tbody> </table> </td> <? } ?> <? $sql2 = "SELECT * FROM games"; $result2 = mysql_query($sql2); $totalplayed = 0; while($row2 = mysql_fetch_array($result2)) { $totalplayed = $totalplayed+$row2["played"]; } ?> <tr> <? $sql2 = "SELECT * FROM games Where category!='Classic Nintendo' AND category!='Video' AND category!='Other' AND category!='GBC' ORDER BY played DESC LIMIT 2,2"; $result2 = mysql_query($sql2); while($row2 = mysql_fetch_array($result2)) { ?> <td width="50%" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="3" class="game"> <tbody> <tr align="left" valign="top"> <td align="center" width="33%"><span class="normalText"> <a href="play-flash-<? echo $row2["gameid"]; ?>.html"> <img src="http://files.atarcade.com/img/<? echo $row2["image"]; ?>" alt="<? echo $row2["name"]; ?>" border="0" height="60" width="60"></a></span></td> <td class="normalText"> <b> <a href="play-flash-<? echo $row2["gameid"]; ?>.html"> <? echo $row2["name"]; ?> </a></b><br> <?php $max_length = 55; if (strlen($row2['desc'])>$max_length) echo substr($row2['desc'], 0, strrpos(substr($row2['desc'], 0, $max_length), ' ')).'.'; else echo $row2["desc"]; ?> <br> </tr> </tbody> </table> </td> <? } ?> <? $sql2 = "SELECT * FROM games"; $result2 = mysql_query($sql2); $totalplayed = 0; while($row2 = mysql_fetch_array($result2)) { $totalplayed = $totalplayed+$row2["played"]; } ?> </tr> </table></td></tr><tr> <td><table width="100%" border="0" cellpadding="0" cellspacing="0" class="categFoot"> <tr><td><div align="right"> <a href="top-100-games.html" class="blackLink">View Top 100 Flash Games ...</a> </div></td></tr></table></td></tr></table></td></tr></table> does anyone know how I can optimize this to use less server resources, I want it to look the same but just use less resources, this code gets the job done but it uses so much CPU seconds. Any help would be grateful, I don't know how to combine the two parts into one so it displays the same. Thanks. Link to comment https://forums.phpfreaks.com/topic/73548-small-script-uses-to-much-cpu-seconds/#findComment-371084 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.