pagination

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jauson
Forum Contributor
Posts: 111
Joined: Wed Oct 05, 2011 12:59 am

pagination

Post by jauson »

Code: Select all

<?php

include 'conn.php';

$query = "SELECT * FROM `r_user` ORDER BY `id` DESC LIMIT 0, 5";
$result = mysql_query($query);
?>
<html>
<head><title> PHP </title></head>
<body>
<h3> Database </h3><br>
<table border="1" align="center" width="600">
   <tr>
   <td align="center"><font size="2"><strong> ID </font></strong>
	  <td align="center"><font size="2"><strong> First Name </font></strong>
		<td align="center"><font size="2"><strong> Last Name </font></strong>
		  <td align="center"><font size="2"><strong> Priveledges </font></strong>
		    <td align="center"><font size="2"><strong> Username </font></strong>
		</tr>
			<?php while($rows = mysql_fetch_assoc($result)) { ?>
			<tr>
			<tr>
			<td> <? echo $rows ['id']; ?> </td>
			<td> <? echo $rows ['firstname']; ?> </td>
			<td> <? echo $rows ['lastname']; ?> </td>
			<td> <? echo $rows ['priveledges']; ?> </td>
			<td> <? echo $rows ['username']; ?> </td>
			</tr>
		<? }
			mysql_close();
		?>
	</table>
</html>
I want to make this page with pagination can you show me how to work at it?
Last edited by Benjamin on Fri Oct 21, 2011 2:21 am, edited 1 time in total.
Reason: Added [syntax=php|sql|css|javascript] and/or [text] tags.
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: pagination

Post by twinedev »

I had written up a good sample and example, however since this is in the tutorials section, I have to toolbar to allow me to post code here on how to achieve it with the code you have. Unfortunately, I closed the the virtual machine I wrote it on, and lost the file I played with. If I get time, I'll try to rewrite it and submit some other way where I can paste it as code (too ugly to just post here)
mikeashfield
Forum Contributor
Posts: 159
Joined: Sat Oct 22, 2011 10:50 am

Re: pagination

Post by mikeashfield »

This seems to explain it clearly enough for me:

http://php.about.com/od/phpwithmysql/ss ... nation.htm
Post Reply