| 
<?php
 /*
 this example is used to obtain a number of data with display limitation into the pages, with jQuery .load() plus CSS Rules. related with example3.php
 author: usman didi khamdani
 author's email: [email protected]
 author's phone: +6287883919293
 */
 
 if((isset($_GET['auth']) && $_GET['auth']!="")) {
 
 // define first, prev, next and last thumbnail
 define("_FIRST","<img src=\"images/first.png\" alt=\"First\" />");
 define("_PREV","<img src=\"images/prev.png\" alt=\"Prev\" />");
 define("_NEXT","<img src=\"images/next.png\" alt=\"Next\" />");
 define("_LAST","<img src=\"images/last.png\" alt=\"Last\" />");
 
 include("paging.class.php");
 
 $host = "localhost"; // database host name
 $user = "root"; // database user name
 $password = ""; // database user password
 $db = "test"; // database name
 
 $host_conn = mysql_connect($host,$user,$password); // connect to host
 if(!$host_conn) {
 die(mysql_error());
 }
 $db_conn = mysql_select_db($db, $host_conn); // connect to database
 if(!$db_conn) {
 die(mysql_error());
 }
 
 // current page
 if(isset($_GET['page']) && $_GET['page']!="") {
 $page = @$_GET['page'];
 } else {
 $page = 1;
 }
 
 // setting param
 $param1 = $_GET['auth'];
 
 $param = "auth=$param1";
 
 $query1 = "SELECT no FROM book WHERE Author = '$param1'";
 $check = mysql_query($query1);
 
 if(!$check) {
 die(mysql_error());
 }
 
 $sum_data = mysql_num_rows($check); // sum of data
 
 $max_row = 10; // maximum number of rows of data to be displayed in a page
 $num = 5; // number of page thumbnails
 
 $d = new Paging($page,$max_row,$sum_data);
 
 // get limit;
 $query2 = "SELECT * FROM book WHERE Author = '$param1' ORDER BY Category,Title ".$d->limit();
 // create thumbnail;
 $thumbnail = $d->thumbnail($num,$param);
 
 echo "<div id=\"display_content\"><p>current page = $page<br />number of page = ".ceil($sum_data/$max_row)."<br />maximum number of rows of data to be displayed in a page = $max_row<br />sum of data = $sum_data<br />number of page thumbnails = $num</p><p>mysql_query = <strong>$query2</strong></p>";
 
 $display = mysql_query($query2);
 
 if(!$display) {
 die(mysql_error());
 }
 
 echo "<hr /><h3>List of Books by $param1</h3><table id=\"content\"><tr><th>No.</th><th>Category</th><th>Title</th><th>Published Year</th></tr>";
 $no = 0;
 while($data = mysql_fetch_array($display)) {
 $no++;
 $n = (($page-1)*$max_row)+$no;
 echo "<tr><td style=\"text-align:right\">$n.</td><td>".$data['Category']."</td><td>".$data['Title']."</td><td>".$data['Published_Year']."</td></tr>";
 }
 
 echo "</table></div>$thumbnail";
 } else {
 return false;
 }
 
 ?>
 |