views:

46

answers:

0

Hi, I am currently working for a highscore system for my games website. and i have written the code for that. it only displays 1- players. i want to display overall top players when i click on top players url and want to display the monthly top 10 players when i click on monthly top players url.How to do this. i am trying since 2 days. i am struck at this point. kindly do look into this. the code as follows. For reference kindly look inot this. i need like this. any ideas.. http://www.gamesheep.com/highscores.php?id=the-champions-3d-game&table=w

<?php
include_once("_data.php");

$game_name = "test";
$db_table = "newhs_" . $game_name;

$conn = mysql_connect($db_host, $db_user, $db_pass);
mysql_select_db($db_name, $conn);

// Alltime  records...

if ($order=="name") {
 $sql1 = "SELECT id FROM $db_table ORDER BY name ASC";
} else {
 $sql1 = "SELECT id FROM $db_table ORDER BY score DESC";
}
$result1 = mysql_query($sql1);

// Top 10 players....

if($top10 == "name"){
 $sql2 = "SELECT name,score FROM $db_table ORDER BY score DESC LIMIT 10";
} else {
 $sql2 = "SELECT id FROM $db_table ORDER BY score DESC";
}
$result2 = mysql_query($sql2);

// Monthly top 10 players.....

if($mtop10 == "name"){
 $sql3 = "SELECT name, score FROM $db_table WHERE date(dateinfo) = CURdate()";
} else{
 $sql3 = "SELECT id FROM $db_table ORDER BY score DESC";
}
$result3 = mysql_query($sql3);


if (!$flash) {
 if ($order == "name") {
  $HTM_1 = "<table cellpadding='0' cellspacing='0' border='0' width=" . $table_width . ">
    <tbody>

    <tr align=center><td>" . $table_prop . "<tr align=center> 
  <th bgcolor='" . $t_color . "'>" . $t_font . "Pos</font></th>
  <th bgcolor='" . $t_color . "'>" . $t_font . "Name</a></font></th>
  <th bgcolor='" . $t_color . "'>" . $t_font . "'>Score</font></th>
  </tr>";
 } else {
  $HTM_1 = "<table cellpadding='0' cellspacing='0' border='0' width=" . $table_width . ">
    <tbody>
  <tr align=center><td>" . $table_prop . "<tr align=center> 
   <th bgcolor='" . $t_color . "'>" . $t_font . "Pos</font></th>
   <th bgcolor='" . $t_color . "'>" . $t_font . "Name</a></font></th>
   <th bgcolor='" . $t_color . "'>" . $t_font . "Score</font></th>
  </tr>";
 }
 echo "$HTM_1";
}

$num = 1;

while($r = mysql_fetch_object($result1))
{
 $result = mysql_db_query($db_name, "SELECT name, score from $db_table WHERE id='{$r->id}'");
 $resultArray = mysql_fetch_array($result);
 $id = $resultArray["id"];
 $name = $resultArray["name"];
 $score = $resultArray["score"];
 if ($sec==1) {
  if ($num <= $sec_size) {
   $HTML = "
   <tr bgcolor='" . $m_color . "' align='center'><td>" . $m_font . $num . "</td>
   <td>" . $m_font . $name . "</font></td>
   <td>" . $m_font . $score . "</font></td>
   </tr>";
  echo "$HTML";
  }
 } else {
  if ($num <= $st_size) {
  //echo "&name$num=$name&score$num=$score";
   if ($flash == 1) {
    echo "&name$num=$name&score$num=$score";
   } else {
       echo "&name$num=$name&score$num=$score&num$num=$num&gamename=$game_name";
    $HTML = "
   <tr bgcolor='" . $m_color . "' align='center'><td>" . $m_font . $num . "</td>
    <td>" . $m_font . $name . "</font></td>
    <td>" . $m_font . $score . "</font></td>
    </tr>";
    echo "$HTML";
   }
   $num++;
  }
 }
}

mysql_close ($conn);
?>