Hello, I have a site of some product list. In this site i have code to display page numbers. But i have problem in this code there is showing how many pages in database. But i want to display like this.. But in this case i want to display 1 to 20 page and as like google function. Please help me . Here is my code ################################# <?php $records_per_page=20; $sql="select * from c_detail "; $result=mysql_query($sql); $total_records=mysql_num_rows($result); $pages=ceil($total_records/$records_per_page); $page=$_GET['page']; if(!isset($page)) $page=1; $start=($page-1)*$records_per_page; $sql="Select * from c_detail order by itemid desc LIMIT $start,$records_per_page"; $result=mysql_query($sql) or die(mysql_error()); echo"</br>"; $color1 = "#EEEEEE"; $color2 = "#FFFFFF"; $row_count = 0; if(mysql_num_rows($result)<1){ echo"<div align='center'>"; echo "<font color='red'>No Item in This Category</font>"; echo"</div>"; }else{ echo"<table width='100%' align='center' class='data' cellspacing=0>"; echo"<tr class='ClassHeader'height=22 ><td width='45%' align='center'>Title</td><td width='25%' align='center'>Asking Price(BDT)</td><td width='15%' align='center'>Location</td><td width='15%' align='center'>Post on</td></tr>"; while($row=mysql_fetch_array($result)){ $id=$row['itemid']; $cid=$row['catid']; $title=$row['title']; $location=$row['location']; $price=$row['price']; $date=$row['postdate']; $visit=$row['visitcount']; $row_color = ($row_count % 2) ? $color1 : $color2; echo"<tr bgcolor='$row_color' height=30><td >"; echo "<a href=\"item_list_view_detail.php?id=$id \" class='part7'>$title ($visit)</a>"; echo"</td><td align='center'>"; echo "$price "; echo"</td><td align='center'>"; echo "$location"; echo"</td><td align='center'>"; echo"$date"; echo"</td><tr>"; $row_count++; } } echo"</table>"; // //if ($page > 1) { //$url = "show.php?screen=" . $page - 1; //echo "<a href=\"$url\">Previous</a>\n"; //} // page numbering links now echo "<div align='right' >"; if($pages>1){ echo"Page No >> "; for ($i = 1; $i <= $pages; $i++) { $url = "index.php?page=" .$i; echo "| <a href=\"$url\">$i</a> "; } } echo "</div>"; //if ($screen < $pages) { //$url = "example.php?screen=" . $screen + 1; //echo "<a href=\"$url\">Next</a>\n"; //} ?>
Hello, Thanks for replying me. Would u plz rewrite my code.I am a very beginner php programmer so i cant understand what you r saying.