Site Cloner PHP Script
Bargain Hunter PHP Script
Job Hunter PHP Script
Site Login and Access Control PHP Script

Jquery Pagination and PHP

This example uses a Jquery plugin called DataTables to paginate results from PHP or mySQL. For example, the results could be many items from an rss feed or rows from a mySQL query. The plugin can be dowloaded at This plugin makes it very easy to automatically sort ant amount of data into a clean, paginated, stylish table.

To use DataTables,
1) Download it.
2) Add the plugin script into the head of your file.
3) Add a Jquery function to initialize it:
4) Make sure your <table> has id=”example” and you use <thead> and <tbody> tags. The file pagination_datatables_bare_bones.php already has done this.
5) Customize the css.
$db= public_db_connect();



<script src="//" type="text/javascript"></script>
<script src="DataTables/media/js/jquery.dataTables.min.js" type="text/javascript"></script>


####can put links too.
$link1= "{$_SERVER['PHP_SELF']}?orderby=lastname";
//$my link = '<td align="left"><a href="'.$link1.'"><b>First Name</b></a></td>';
		//echo $order_by;		
	echo '<table  class="display" id="example" align="center" cellspacing="0" cellpadding="5" bgcolor="#E0606B" width="100%">
		<th align="left"><b>Last Name</b>'.' '.'<a href="'.$_SERVER['PHP_SELF'].'?orderby=lastname asc"><b>asc</b></a>'.' '.'<a href="'.$_SERVER['PHP_SELF'].'?orderby=lastname desc"><b>desc</b></a></th>
		<th align="left"><a href="'.$_SERVER['PHP_SELF'].'?orderby=lname"><b>First Name</b></a></th>
		<th align="left"><b>Email</b></th>
		<th align="left"><b>Age</b></th>
		<th align="left"><b>Weight</b></th>
		<th align="left"><b>Height</b></th>
		<th align="left"><b>Date</b></th>

$command = "select * from table_sort ORDER by date DESC"; 
$result = mysqli_query($db, $command);
				$command2= "SELECT DISTINCT email, firstname, lastname, age, weight, height, date FROM table_sort ORDER BY lastname asc ";
				$result2 = mysqli_query($db, $command2);
				if ($result2 && mysqli_num_rows($result2) > 0) {
			    echo  '<tbody>';
			   while ($row = mysqli_fetch_assoc($result2)) {
		$bg =($bg=='#A7C6BA' ? '#f9f9f9' : '#A7C6BA');
		echo '<tr bgcolor="' . $bg . '">
			<td align="left">' .$row["lastname"]. '</td>
			<td align="left">' .$row["firstname"]. '</td>
			<td align="left">' .$row["email"]. '</td>
			<td align="left">' .$row["height"]. '</td>
			<td align="left">' .$row["age"]. '</td>			
			<td align="left">' .$row["weight"]. '</td>
			<td align="left">' .$row["date"]. '</td>
	echo '</tbody></table>';	


<div style="text-align:center;"></div>