Hi , How To create multipage with php/mysql ? for example we have 200 Entry in mysql , and we want to show every 20 entry in one page , then system show such thing : index.php?page=1 ..2..3 and more... Tnx.
Think you need to append your sql query with a limit command. Google 'sql limit' and you will see a bunch of examples.
yes , i use 'sql limit' , but how to create number of pages automaticly ? for example Page : 1 , 2, 3 , 4...and more.
I guess you can do a sql count() of the results and then divide by number of items you want per page, this will give you the number of pages.
It's call pagination this site may help you http://www.strangerstudios.com/sandbox/pagination/diggstyle.php
hai see the following coding This is sample coding you change for you convenients............... <? include("database.php"); include("includes/functions.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="en" /> <meta http-equiv="imagetoolbar" content="no" /> <meta name="keywords" content="" /> <meta name="description" content="" /> <meta name="author" content="www.studio7designs.com" /> <meta name="robots" content="all, follow" /> <meta name="googlebot" content="index, follow, snippet, archive" /> <link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen, projection" /> <link rel="shortcut icon" href="favicon.ico" /> <link rel="stylesheet" href="includes/style.css" type="text/css" /> <script type="text/javascript" language="javascript" src="includes/validate.js"></script> <script type="text/javascript"> </script> <title>My Comments</title> <style type="text/css"> <!-- .style1 { color: #000099; font-weight: bold; } .style4 {color: #008000; font-family: Georgia, "Times New Roman", Times, serif; } --> </style> </head> <body scrolling=no> <div class="page"> <h3 class="header"> <a href= title="Home"><span></span></a> </h3> <ul class="topmenu"> <li><a href="login.php">LOGIN</a></li> <li><a href="lastest.php">LATESETS</a></li> <li><a href="popular.php">POPULAR</a></li> <li><a href="home.php">HOME</a></li> </ul> <div class="main"> <div class="bluebox"> <p class="style1"><span class="style4">SELECT YOUR CATEGORY</span> - </p> <p class="style1"><br /> <br /> <? $r=mysql_query("select *from tbl_admin_category"); $count=0; $totcount=0; while ($res=mysql_fetch_array($r)) { if (($totcount >1)&&($totcount%8==0)) { echo '<br>'; } if ($_GET['next']=="") { if ( $count <8) { $totcount=$totcount+1; ?> <a href="subcategories-<? echo $res['cat_id'] ?>.html"><? echo $res['cat_name'] ?></a> <strong><font color="#CC0000">-</font></strong> <? } else { ?> <br /> <center><a href="home.php?next=<? echo $count ?>" ><strong><font color="#FF0000">Next</font></strong></a></center> <? break; } } else { if ($count >=$_GET['next']) { ?> <a href="subcategories-<? echo $res['cat_id'] ?>.html"><? echo $res['cat_name'] ?></a> <strong><font color="#CC0000">-</font></strong> <? $totcount=$totcount+1; } if($count > $_GET['next']+7) { ?> <br /> <center><a href="homes.php?next=<? echo $count ?>" ><strong><font color="#FF0000">Next</font></strong></a></center> <? break; } } $count++; } ?> </p> <p class="style1"> </p> <br /> <p class="style1"><span class="style4">POPULAR COMMENTS</span> - </p> <p class="style1"><br /> <br /> <? $count=0; $pop=mysql_query("select *from tbl_subsubcategory where type='popular'"); while ($popr=mysql_fetch_array($pop)) { if (($count >1)&&($count %5==0)) echo '<br><br><br>'; ?> <strong> <a href="comments-<? echo $popr['subsubcat_id'] ?>.html "><font color="#990000" face="Script" SIZE="4">View</font></a></strong> <img src="subsubcategory/<? echo $popr['subsubcat_image'] ?>" width="50" height="50" class="photos" alt="<? echo $popr['subsubcat_name'] ?>"/> <? $count=$count+1; } ?> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> </p> <p class="style1"> <br /> </p> </div> </div> <!-- /photos--> </div> <!-- /main--> <div class="footer1"> <p><br /><br /> <br /><br /><br /><br /><br /><br /><br /> <br /><br /><br /><br /><br /> <br /><br /><br /><br /><br /><br /> <br /><br /><br /><br /><br /> <br /><br /><br /><br />© 2007 <a href="#"> NET AXIS IT SOLUTIONS</a></p> <p><a href="#"><strong>Contact Us </strong></a> </p> </div> </div> <!-- /page--> <div class="footer2"> </div> </body> </html>
thank you himambo, helpful article , phpeasystep.com is your site ? thank you sjmassey , yes that is right.