topical media & game development

talk show tell print

game-php-score-vu-scorelist.php / php



  <?
  server = mysql_connect("localhost",  "USER", "PASS"); 
  mysql_select_db("DB", server);  
  timee=time=time();
  
  game=addslashes(_REQUEST['game']);
  titel=addslashes(_REQUEST['titel']);
  
          
          
  function time_format (time){
           nu=time();
           if((nu-600)<time){
                  per="<font color=green>";        
          }else if((nu-1800)<time){
                  per="<font color=orange>";        
          }else{
                  per="<font>";
          }
   
           out=per.date("Y-m-d H:i", time)."</font>";
          return out;
  }
  
  ?>
  <html>
          
          <head>
                  <title><? echo title; ?></title>
          </head>
  
          <body bgcolor="#717E8E" alink=ffffff vlink=cccccc link=ffffff>
                  <center>
                                  
                          <img src=beker.jpg /><br />
                          <?
                          if(game=='VUgame'){
                                  echo"<a href=index.php><b></b>Back to the game</b></a><br />";
                          }
                          ?>
                          <table>
                          <tr valign=top><td>
                  <?        
                  echo "<b>Top 50 worldwide:</b><br />";
          
                  
                  echo"<table width=250 cellpadding=5 border=0>
                  <tr><td><td>Name</b><td>Time</b><td>Date</b></td></tr>"; i=1;
                  sql = "SELECT name, score, time FROM highscores WHERE game='game' ORDER by score ASC LIMIT 50";            
                     resultaat = mysql_query(sql);     
              while (record = mysql_fetch_object(resultaat))
                  {
                   if(BG!="#7B8491"){BG="#7B8491"; }else{ BG="#999999"; }
                   echo"<tr bgcolor=BG><td>i<td><b>record->name</b><td>record->score<td><small>".time_format(record->time)."</small></td></tr>";
                   i++;
                  }
                  echo"</table>";
              ?>
              </td><td width=50> </td>
              <td>
              <?        
                  echo "<b>Best times per playername:</b><br />";
  
                                  
                  echo"<table width=250  cellpadding=5 border=0>
                  <tr><td><td>Name</b><td>Best time</b><td>Last online</b></td></tr>"; i=1;
                  sql = "SELECT name, MIN(score) as score, MAX(time) as time FROM highscores  WHERE game='game'  GROUP BY name ORDER by score ASC LIMIT 50";            
                     resultaat = mysql_query(sql);     
              while (record = mysql_fetch_object(resultaat))
                  {
                   if(BG!="#7B8491"){BG="#7B8491"; }else{ BG="#999999"; }
                   echo"<tr bgcolor=BG><td>i<td><b>record->name</b><td>record->score<td><small>".time_format(record->time)."</small></td></tr>";
                   i++;
                  }
                  echo"</table>";
              ?>
              </td><td width=50> </td>
              <td>
              <?        
                  echo "<b>Last 50 laps</b><br />";
  
                  
                  echo"<table width=250  cellpadding=5 border=0>
                  <tr><td><td>Name</b><td>Best time</b><td>Last online</b></td></tr>"; i=1;
                  sql = "SELECT name, score, time FROM highscores  WHERE game='game'  ORDER by ID DESC LIMIT 50";            
                     resultaat = mysql_query(sql);     
              while (record = mysql_fetch_object(resultaat))
                  {
                   if(BG!="#7B8491"){BG="#7B8491"; }else{ BG="#999999"; }
                   echo"<tr bgcolor=BG><td>i<td><b>record->name</b><td>record->score<td><small>".time_format(record->time)."</small></td></tr>";
                   i++;
                  }
                  echo"</table>";
              ?>
              
              </td></tr></table>
                          
                          <small><font color=green>Active the last 10 minutes</font> - <font color=orange>Active the last 30 minutes</font></small>
                  
                  </center>
          </body>
          
  </html>
  
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.