Jump to content

Add Ranking / Standings To My Page???? Help Please


just me and php

Recommended Posts

[code] <body bgcolor="#000000" text="#ffffff" link="gold" vlink="gold" alink="gold">
<?
require "config.php";           
$page_name="3newres.php"; 
if(!isset($start)) {                         
$start = 0;
}

$eu = ($start - 0);
$limit = 200;                                 
$this = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;

echo "<TABLE width=95% align=center  cellpadding=0 cellspacing=0> <tr>";
echo "<bgcolor='black' >&nbsp;<font face='arial,verdana,helvetica' color='gold' size='4'><center><b> HOT LAPS</b></font></center></a><BR>";

echo "<table border='0'><tr>";
//$query = "SELECT * FROM SXHotLap   GROUP BY 'recno' ORDER BY 'recno' DESC limit $eu, $limit ";
$query = "SELECT * FROM SXHotLap   ORDER BY 'Username','track' GROUP BY 'recno' ORDER BY 'recno' DESC limit

$eu, $limit ";
$result = mysql_query($query) or die("There was a problem with the SQL query: " . mysql_error());
$i = 0;
$max_rows = 1000;
$num_rows=mysql_num_rows($result);
while($row = mysql_fetch_array($result))
{

$f1= $row[recno];      //record id           
$f2 = $row[disp];      //bike
$f3 = $row[HL_MS];     //lap time
$f4 = $row[track];     //track
$f5 = $row[Username];  //name
$f6 = $row[date];      //date
$f7 = $row[TRT_MS];    //5 lap time
$f8= $row[online];     //online
$f9 = $row[MP];        //medium player
$f10 = $row[hacked];   // if he runs a hack
$f11 = $row[display];  //display
$f12 = $row[HL_F];     //


if($bgcolor=='#000000'){$bgcolor='#000000';}
else{$bgcolor='#000000';}
if($row[online]=='Y'){$fontcolor ='#00FF00';}
if($row[online]=='N'){$fontcolor ='#FF0000';}
if($row[MP]=='Y'){$fontcolormp ='#00FF00';}
if($row[MP]=='N'){$fontcolormp ='#FF0000';}
if($noticia[hacked]=='26'){$fontcolorhk ='blue';}
if($noticia[hacked]=='24'){$fontcolorhk ='blue';}
if($noticia[hacked]=='22'){$fontcolorhk ='blue';}
if($noticia[hacked]=='20'){$fontcolorhk ='blue';}
if($noticia[hacked]=='18'){$fontcolorhk ='blue';}
if($noticia[hacked]=='16'){$fontcolorhk ='blue';}
if($noticia[hacked]=='14'){$fontcolorhk ='blue';}
if($noticia[hacked]=='12'){$fontcolorhk ='blue';}
if($noticia[hacked]=='9'){$fontcolorhk ='blue';}
if($noticia[hacked]=='8'){$fontcolorhk ='blue';}
if($noticia[hacked]=='4'){$fontcolorhk ='blue';}
if($noticia[hacked]=='3'){$fontcolorhk ='blue';}
if($noticia[hacked]=='1'){$fontcolorhk ='blue';}
if($noticia[hacked]=='0'){$fontcolorhk ='WHITE';}
if($row[display]=='N'){$f1='';}
if($row[display]=='N'){$f2='';}
if($row[display]=='N'){$f3='';}
if($row[display]=='N'){$f4='';}
if($row[display]=='N'){$f5='';}
if($row[display]=='N'){$f6='';}
if($row[display]=='N'){$f7='';}
if($row[display]=='N'){$f8='';}
if($row[display]=='N'){$f9='';}
if($row[display]=='N'){$f10='';}
if($row[display]=='N'){$f11='';}
if($row[display]=='N'){$f12='';}
if($row[display]=='N'){$f13='';}

$i++;
$br++;
if($i == 1){
echo "<td valign='top'>\n";
echo "<table>\n";


}


if($i<=$max_rows){
echo "<td align=left bgcolor=$bgcolor id='title'><font face='Verdana' size='2'><a href='4newres.php?id=$f1'><B>$f3</B></font></a></td>\n";
echo "<td align=left bgcolor=$bgcolor id='title'><font face='Verdana' size='2'><font color='$fontcolor'><B>$f2</B></font></a></td>\n";
echo "<td align=left bgcolor=$bgcolor id='title'><font face='Verdana' size='2'><a href='members_1.php?id=$f5'><B>$f5</B></font></a></td>\n";
echo "<td align=left bgcolor=$bgcolor id='title'><font face='Verdana' size='1'><a href='$page_name?id=$f4'><B>$f4</B></font></a></td>\n";
echo "<td align=left bgcolor=$bgcolor id='title'><font face='Verdana' size='1'><B>$f6</B></font></a></td>\n";

echo "<tr><td>$row[ID]</td></tr>\n";
}
if($i==$max_rows||$br==$num_rows){
echo "</table>\n</td>\n";
$i=0;
}
}
?>
</tr></table>[/code]

Link to comment
Share on other sites

Ok I Change This Code
[code]$query = "SELECT * FROM SXHotLap   GROUP BY 'recno' ORDER BY 'recno' DESC limit $eu, $limit ";
[/code]

To This

[code]$query = "SELECT * FROM SXHotLap   GROUP BY 'Username','track' ORDER BY 'recno' DESC limit $eu, $limit ";
[/code]

And Now It Post Like I Wanted, But I Think I Need Some Kinda MIN Statment For The Table HL_MS, The Reason I Need Something Like MIN Is So It Will Post The Fastest Lap Time , Now It Post The Last Lap Time The Racer Did.

Can Someone Help Me With A MIN Code I Think It Needs To Be In This Below.But Not Sure
[code]$query = "SELECT * FROM SXHotLap   GROUP BY 'Username','track'  ORDER BY 'recno' DESC limit $eu, $limit ";
[/code]
Link to comment
Share on other sites

If you list your columns in the select, you can do things like this:

[code=php:0]SELECT username, min(HL_MS), ... FROM SXHotLap[/code]

The min() will take effect after the GROUP BY.  You should group by whichever columns you want to do a minimum over.

For example, if you want the minimum for each username and track, you should "GROUP BY Username, track"
Link to comment
Share on other sites

Thanks For The Help , But I Think Im Doing It Wrong , When I Use This Code Below , It Doesnt Show The HL_MS Table (laptimes)if i take the min() off and just leave HL_MS it shows the laptimes

[code]$query = "SELECT recno,disp,track,Username,date, MIN(HL_MS) FROM SXHotLap GROUP BY 'Username','track'  ORDER BY 'recno' DESC  limit $eu, $limit ";
[/code]
what am i doing wrong?
Link to comment
Share on other sites

Sorry, I left something out:

[code=php:0]$query = "SELECT recno,disp,track,Username,date, MIN(HL_MS) AS HL_MS FROM SXHotLap GROUP BY 'Username','track'  ORDER BY 'recno' DESC  limit $eu, $limit ";[/code]


The difference is adding "AS HL_MS".  Otherwise the result column will be called "min".  That'll be why you couldn't get the results out.
Link to comment
Share on other sites

Sorry To Reopen This But If You Could Help Me A Little More That Would Be Great.

I Want To Add A Count To My Page And Im Not Sure If This Can Even Be Done With Out Adding Something To Data Base But This Is What Im Looking For.

This Is What I Have
   lap time  bike   name    track      date and time

   0:53.99   600   racer1   track1   11/14/2006 7:15:49 PM

   1:03.57   426   racer1   track1   11/14/2006 6:02:31 PM
     
   0:54.94   426   racer2   track1   11/11/2006 7:54:17 PM

   0:47.63   250   racer2   track1   11/11/2006 8:55:56 PM

   0:56.28   600   racer2   track2   11/10/2006 8:40:08 PM

And This Is What Im Looking For
Standings  lap time  bike   name    track      date and time

       1          0:53.99   600   racer1   track1   11/14/2006 7:15:49 PM

       6          1:03.57   426   racer1   track1   11/14/2006 6:02:31 PM
     
      34          0:54.94   426   racer2   track1   11/11/2006 7:54:17 PM

        5         0:47.63   250   racer2   track1   11/11/2006 8:55:56 PM

     345         0:56.28   600   racer2   track2   11/10/2006 8:40:08 PM

Standings Would Be Based Off Of ,Lap time, Bike, Username ,Track, And It Would Mean That Username Is Sum Number Of Top #1 Fatested Lap Time On That Bike And On That Track.

Can Some Help Me Do This ?
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.