Hello yet again, well this is probably the last question, so sorry if im buggy.
But, its a ranking system.
If you haven't noticed my other topic, im making like a Voting system with shows the Rank of who is coming first, etc.
And this is what i have gotten so fare:
<?php
//Connecting to database here
//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");
echo "<center><table border='2' cellpadding='7' cellspacing='0' table width='600'></center>";
echo "<center><tr> <th>Server Name</th> <th>Votes</th> <th>Details</th><th>Rank</th></tr></center>";
while ($row = mysql_fetch_assoc($get))
{
if (strlen($row['details']) > 10) // if len is more than 10
{ // shorten it and add trailing dots.
$details = substr($row['details'], 0, 15) . "...";
}
else // len is less than 10, use original description.
{
$details = $row['details'];
}
$query = "
SELECT votes
FROM data
WHERE votes
ORDER BY position DESC
";
$result = mysql_query($query);
$place = 1;
// get data
$sname = $row['sname'];
$svotes = $row['votes'];
echo "<tr><td>";
echo "<center>$sname</center>";
echo "</td><td>";
echo "<center>$svotes</center>";
echo "</td><td>";
echo "<center>$details</center>";
echo "</td><td>";
echo "<center>$place</center>";
$place++;
}
echo "</table>";
//setup prev and next variables
$prev = $start - $per_page;
$next = $start + $per_page;
//show prev button
if (!($start<=0))
echo "<a href='index.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='index.php?start=$x'>$i</a> ";
else
echo " <a href='index.php?start=$x'><b>$i</b></a> ";
$i++;
}
//show next button
if (!($start>=$record_count-$per_page))
echo " <a href='index.php?start=$next'>Next</a>";
?>
Here is the site:
http://toplist.ulmb.com/index.php
What this is supposed to do, Is tally up the votes from the Votes field, and put them in rankings. The highest person with the highest amount of votes goes #1, and i want to be able to show that.
As you can see, in the Ranking there is just 1, i tried viewing a few websites, and this is the closest i could get.
Any help?