Forum Moderators: coopster
$query_list = "SELECT * FROM user_char order by rank * 1 asc where rank >= $row[rank]";
for some reason that will not work. Im not sure why. Can you use >= in a select statment?
anyhow, the reason I have it like this is for pagination, I would like to display the user first and then the users with a lesser rank in order, but I do not want to have problems when another page is clicked, Im not sure if this will interfere or not. anyhow help would be appreciated.
Maybe someone can suggest some code, I would like to display the logged in user at the top of the page, then the users with a lower rank below him, but there will be many many users above and below his rank, so I would still like to be able to use NEXT and PREVIOUS links to display users much higher and lower than the logged on user.
if anyone knows how I can do this please let me know.
<?
/* Set current, prev and next page */
$page = (!isset($_GET['page']))? 1 : $_GET['page'];
$prev = ($page - 1);
$next = ($page + 1);
/* Max results per page */
$max_results = 5;
/* Calculate the offset */
$from = (($page * $max_results) - $max_results);
/* Query the db for total results. You need to edit the sql to fit your needs */
$result = mysql_query("select * from user_char");
$total_results = mysql_num_rows($result);
$total_pages = ceil($total_results / $max_results);
$pagination = '';
/* Create a PREV link if there is one */
if($page > 1)
{
$pagination .= '<a href="page4.php?page='.$prev.'">Previous</a> ';
}
/* Loop through the total pages */
for($i = 1; $i <= $total_pages; $i++)
{
if(($page) == $i)
{
$pagination .= $i;
}
else
{
$pagination .= '<a href="page4.php?page='.$i.'">$i</a>';
}
}
/* Print NEXT link if there is one */
if($page < $total_pages)
{
$pagination .= '<a href="page4.php?page='.$next.'">Next</a>";
}
/* Now we have our pagination links in a variable($pagination) ready to print to the page. I pu it in a variable because you may want to show them at the top and bottom of the page */
/* Below is how you query the db for ONLY the results for the current page */
$result = mysql_query("select * from user_char LIMIT $from, $max_results ");
while ($row = mysql_fetch_array($result))
{
echo $row[rank];
/* This is where you print your current results to the page */
}
?>
I am getting this error
Parse error: parse error, unexpected $ in /home/acewebde/public_html/game/page4.php on line 60
which is this line,?>
now I do not understand why I am getting that error.