Jump to content

[SOLVED] problem with pagination


uwannadonkey

Recommended Posts

???

 

i found this code on one of the topics

i think its guilty's

<?php
include('inc/header.php');
$con = mysql_connect("localhost","donkey9_Admin","***");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("donkey9_Game", $con);

$page_num = $_GET['page'];
if(empty($page_num))
{
$page_num = 1;
}
$ppp = 5; //posts per page
$min_ppp = ($ppp*$page_num)-$ppp;
$query = mysql_query("SELECT * FROM users") or die(mysql_error());
$num_rows = mysql_num_rows($query);
$query = mysql_query("SELECT * FROM users ORDER BY 
level LIMIT $min_ppp, $ppp") or die(mysql_error());
$rows = mysql_num_rows($query);
$pages = ceil($num_rows/$ppp);

while($row = mysql_fetch_array($query))
{
$first_name = $row['ID'];
$last_name = $row['display_name'];
$points = $row['level'];
$tutor = $row['gold'];


echo "<table><tr><td>$first_name $last_name</td><td>$tutor</td>/<td>$points<td/></tr></table>";
}

if($page_num == 1)
{
echo "Prev ";
} else
{
	$prev_page = $page_num-1;
	echo "<a href=\"{$PHP_SELF}?page={$prev_page}\">Prev</a>";
}
for($i = 1; $i <= $pages; $i++)
{
if($i == 1)
{
	echo " ";
}
if($i == $page_num)
{
	echo $i;
} else
	{
		echo "<a href=\"{$PHP_SELF}?page={$i}\">{$i}</a>";
	}
if($i != $pages)
{
	echo ", ";
} else
	{
		echo " ";
	}
}
if($page_num == $pages)
{
echo "Next";
} else
{
	$next_page = $page_num+1;
	echo "<a href=\"{$PHP_SELF}?page={$next_page}\">Next</a>";
}
mysql_close($con)





?>

 

well i was editing it, i wanna turn it into a ranking page for my game, but when i try to do that, this happens:

 

/

4 dime 0 1

/

5 tommy 0 1

/

6 The Prophet 71 1

/

7 D4rksorrow 500 1

/

12 Dracor 338 1

 

where do the slashes come from? and how do i make them all lined up in a table? i tried to do it, but its not working?

Link to comment
Share on other sites

while($row = mysql_fetch_array($query))
{
$first_name = $row['ID'];
$last_name = $row['display_name'];
$points = $row['level'];
$tutor = $row['gold'];


echo "<table><tr><td>$first_name $last_name</td><td>$tutor</td>/<td>$points<td/></tr></table>";
}

 

The key is right here in this block of code. Notice, your in a while loop, so your creating whole new tables for this text, the slash comes from between $tutor</td> / <td>$points

 

Try this.

 

 

<table>
<?php
while($row = mysql_fetch_array($query))
{
$first_name = $row['ID'];
$last_name = $row['display_name'];
$points = $row['level'];
$tutor = $row['gold'];

echo "<tr><td>$first_name $last_name</td><td>$tutor</td><td>$points<td/></tr>";

}
?>
</table>

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.