Hi, i created the page which is display some information from database with some rules in the end of page i putted the command that it is show how many page that i have.
so, i decide to add next and previous in the sides of page numbers and also i wanna mark active page for visitor (for ex : type active page with bold style)
here is the code :
<?php
include "db.php";
//Rows
$qtyRow = '<tr>';
$priceRow = '<tr>';
$nn=6; //Number of items, we split this later
$s=mysql_query("SELECT * FROM `test1`");
$c=mysql_num_rows($s);
if($c%$nn==0){
$cc=$c/$nn;
}else{
$cc=$c/$nn+1;
}
//$cc : Number of pages
$ss=@$_REQUEST['ss']; //Start position (eg: 6)
$other_tables = "";
if($ss=="" || $ss==null){
$ss = 0; //Set to zero because it is incremented later
}
//Pages
echo "<table border=\"1\" align=\"center\">";
$sql=mysql_query("SELECT * FROM `test1` ORDER BY `id` DESC LIMIT $ss,$nn");
$inc = 0;
while($r=mysql_fetch_array($sql)){
$id=$r['id'];
$name=$r['name'];
if($inc == 0){
$qtyRow .= "<tr>";
$priceRow .= "<tr>";
}
$qtyRow .= "<td>$id</td>";
$priceRow .= "<td>$name</td>";
++$inc;
if($inc == 3 || $inc == 6 || $inc == mysql_num_rows($sql)){
//Display Table
echo $qtyRow."</tr>";
echo $priceRow."</tr>";
echo "</table>";
//To remove extra table
if(mysql_num_rows($sql) <= 3){
$inc = 7;
}
//Reset
if($inc == 3){
echo "<br><table border='1' align='center'>";
$qtyRow = "<tr>";
$priceRow = "<tr>";
}
}
}
echo "</table>";
$j=0;
echo"page : ";
for($i=1;$i<=$cc;$i++){
echo"<a href=\"select.php?ss=$j\">$i</a>";
echo"|";
$j=$j+$nn;
}
?>