[PHP+SQL script: Top 15] Someone wrong

Yolom

LOMCN Veteran
Veteran
Aug 7, 2010
325
21
45
Spain
I've programmed PHP script TOP 15 linked to SQL. But is not displayed correctly, this messy.

Here is the script:
Code:
<?php
 header("Content-Type: text/html; charset=ISO-8859-1");
 header("Last-Modified: ".gmdate("D, d M Y H:i:s", time())." GMT");;
 header("Expires: ".gmdate("D, d M Y H:i:s", time() + 600)." GMT");
 $title = "Estadisticas Evento";
 ?>
<h2 align="center"><br><font color="#A2FF00"size="6"><?php echo $title ?></font></h2>
<?php
 error_reporting(0);


 $currentTime = date("r", time());
 echo <<<END
 <p align="center"><font color="white">Estadisticas obtenidas fecha: $currentTime</p>
END;


 include('adodb/adodb.inc.php');
 include('00tohtmlnew.inc.php');
 include('00connString.php');
 GLOBAL $gSQLMaxRows,$gSQLBlockRows;
 $gSQLMaxRows = 1000; // max no of rows to download
 $gSQLBlockRows=1000; // max no of rows per table block


 $conn = &ADONewConnection("ado_mssql");
 if (@$conn->PConnect($accountDSN, "", "", "")) {
  print "<p align=\"center\">Jugadores Online: ";
  $output = $conn->GetRow('SELECT TOP 1 FLD_COUNT, FLD_TIME FROM TBL_COUNTLOGS ORDER BY FLD_TIME DESC');
  if (empty($output)) {
   print "Not Available";
  } else {
   print "$output[0]";
  }
  $conn->Close(); // optional
  print "</p>";
 } else {
  print "<p align=\"center\">Server Count: Not Available</p>";
 }


 $conn = &ADONewConnection("ado_mssql");
 if (@$conn->PConnect($gameDSN, "", "", "")) {
  echo <<<END




<table align="center" border="0" width="50%" cellpadding="2" cellspacing="2">
<tr bgcolor="#C0C0C0"><th>Top 15 Recolecta Semana Santa</th></tr>
 <tr bgcolor="#E0E0E0"><td align="center" valign="top">
END;


$recordSet = &$conn->Execute('SELECT TOP 15 FLD_PERSONAJE, FLD_CANTIDAD FROM TBL_EVENTO ORDER BY FLD_CANTIDAD DESC');
if ($recordSet) {
  if ($recordSet->EOF) {
    print "No One";
  } else {
    rs2htmlnum($recordSet, 'BORDER=0', array('Jugador', 'Cantidad'));
  }
  $recordSet->Close(); // optional
} else {
  print "Not Available";
}


  echo <<<END
 </td>
 </tr>
</table>
END;


  $conn->Close(); // optional
 } else {
  print "Statistics is not available because the server is busy or down.";
 }
?>



Here's how it is displayed:
Sin título.png


I hope your help. Thanks
 

Hazuki

VIP
VIP
Apr 14, 2004
3,459
38
285
United Kingdom
SELECT TOP 15 FLD_PERSONAJE, FLD_CANTIDAD FROM TBL_EVENTO ORDER BY FLD_CANTIDAD DESC

change to

SELECT * FROM TBL_EVENTO ORDER BY FLD_CANTIDAD DESC
 
  • Like
Reactions: Yolom

Yolom

LOMCN Veteran
Veteran
Aug 7, 2010
325
21
45
Spain
Thanks for the help, but my intention was to make "Canitdad" go largest number to smallest number.

example:
1 Termineitor 300
2 OnePiece 298
3 Homer 56
4 Marge 2
5 Ash 1