Jump to content

Desending by first number


Twist3d

Recommended Posts

Hello.

Well i have yet ANOTHER problem.

It should be a quite easy one to fix, but for me its not.

 

http://toplist.ulmb.com/viewtoplist.php

 

As you can see by that, 544 is at the top of the list. Which it is the LOWEST number.

But as you can see, its first number (5) is higher then all of the other numbers first number.

How can i make it descend by the full value and not just the first number? So this would make 4444 at the top, and 544 at the bottom.

 

Here is my code:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<style>
.text_button {
   border: none;
   background-color: transparent;
   padding: 0;
   text-decoration: underline; /* if desired */
   color: #00c;  /* or whatever other color you want */
}

.text_button2 {
   border: none;
   background-color: transparent;
   padding: 0;
   font-size: 1.0em;
   text-decoration: underline; /* if desired */
   color: #00c;  /* or whatever other color you want */
}

</style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>View Toplist</title>
</head>
<a href=index.php><center><img src="images/Banner.jpg" width="580" height="142" /></center></a>
<?php

//connecting to mysql database

//max displayed per page
$per_page = 20;

//get start variable
$start = $_GET['start'];

//count records
$result=mysql_query("SELECT COUNT(*) FROM data") or die( mysql_error() ); 
$record_count = mysql_result($result , 0); 

//count max pages
$max_pages = $record_count / $per_page; //may come out as decimal

if (!$start)
   $start = 0;
   
//display data
-----$get = mysql_query("SELECT * FROM data ORDER BY votes DESC LIMIT $start, $per_page"); -------
$G=$start;
while ($row = mysql_fetch_assoc($get))
{
if (strlen($row['sdetail']) > 10) // if len is more than 10 
{ // shorten it and add trailing dots. 
$sdetail = substr($row['sdetail'], 0, 100) . "..."; 
} 
else // len is less than 10, use original description. 
{ 
$sdetail = $row['sdetail']; 
} 

// get data
$sname = $row['sname'];
$svotes = $row['votes'];
$id = $row['ID'];

$G++;
?>

<body>
<div align="center">
<img src="/images/navbar.png" width="720" height="25" />
</div>
<table width="1328" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutDefaultTable-->
  <tr>
    <td width="428" height="3"></td>
    <td width="88"></td>
    <td width="47"></td>
    <td width="431"></td>
    <td width="88"></td>
    <td width="246"></td>
  </tr>
  <tr>
    <td height="56"> </td>
    <td valign="top"><div align="center"><?php echo $G; ?></div></td>
    <td> </td>
    <td valign="top"><?php echo "

<form action='viewinfo.php' method='get'>
<input type='hidden' name='id' value='$id'/>
<input type='submit' class='text_button' value='$sname'/>
"; ?><br />
        <?php echo " $sdetail"; ?></td>
        <?php echo "</form>";?>
    <td valign="top"><div align="center"><?php echo $svotes; ?><br />
     <font size="1"> <?php echo "

<form action='voteserver.php' method='get'>
<input type='hidden' name='id' value='$id'/>
<input type='submit' class='text_button2' value='[Vote for this server]'/>

"; ?> </font> </form>
   
  </div></td>
  <td> </td>
  </tr>
</table>

<?php
}
echo "<center>";
//setup prev and next variables
$prev = $start - $per_page;
$next = $start + $per_page;

//show prev button
if (!($start<=0))
  
       echo "<a href='viewtoplist.php?start=$prev'>Prev </a>";

//show page numbers

//set variable for first page
$i=1;
for ($x=0;$x<$record_count;$x=$x+$per_page)
{
if ($start!=$x)
    echo "<a href='viewtoplist.php?start=$x'>$i </a>";
else
    echo "<a href='viewtoplist.php?start=$x'><b>$i </b></a>";
$i++;
}
//show next button
if (!($start>=$record_count-$per_page))
       echo "<a href='viewtoplist.php?start=$next'>Next</a>";
echo "</center>";
?>
</body>
</html>

 

I have put the Query of the descending order in ----- -----

Any help.

Link to comment
https://forums.phpfreaks.com/topic/185833-desending-by-first-number/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.