Login   Register  
PHP Classes
elePHPant
Icontem

File: sample4.txt

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Shiegege  >  Paging for MySQL  >  sample4.txt  >  Download  
File: sample4.txt
Role: Example script
Content type: text/plain
Description: Simple Sample Table
Class: Paging for MySQL
Create a query results page navigation bar
Author: By
Last change: add url
Date: 10 years ago
Size: 1,028 bytes
 

Contents

Class file image Download
<?
// see online: http://kentung.f2o.org/scripts/paging/sample4.php
require("paging_class.php");

// create table //
$td=3;
$tr=4;

$paging=new paging(($td*$tr),5);
$paging->db("localhost","username","password","dbname");
$paging->query("select * from paging order by MY_FIELD asc");

$page=$paging->print_info();
    echo 
"Data $page[start] - $page[end] of $page[total] [Total $page[total_pages] Pages]<hr>\n";

$table_tr=ceil(($page[total]-$page[start]+1)/$td);
if (
$table_tr>$td$table_tr=$tr;
$table_td=($page[total]-$page[start])+1;
if (
$table_td>$td$table_td=$td;

echo 
"<table border=\"1\">";
for (
$i=1;$i<=$table_tr;$i++) {
    echo 
"<tr>";
        for (
$j=1;$j<=$table_td;$j++) {
            
$result=$paging->result_assoc();
            
$color=$paging->print_color("yellow","#FFCCCC");
            
$number=$paging->print_no();
                if (
$number>$page[total]) {$number="&nbsp;";}
            echo 
"<td bgcolor=\"$color\">$number $result[MY_FIELD]</td>";
        }
    echo 
"</tr>\n";
}
echo 
"</table>";

echo 
"<hr>".$paging->print_link();
?>