Jump to content

Small script uses to much CPU seconds


Recommended Posts

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
Share on other sites

 

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.