With the code bellow i want to be able to remove the "ID LIMIT 50" and have the code with pagenation instead but i have problems, i have tried some solutions and failed, is there someone that can help me with this please? :/ <div id="block" border="1" width="200" style="float:center">'; $i = 0; $getquery=mysql_query("SELECT * FROM dogs ORDER by ID LIMIT 50"); while($rows=mysql_fetch_assoc($getquery)){ $id=$rows['id']; echo '<a href="/index.php?dogs='. $id .'"> <img src="/thumbs/'. $id .'.jpg" width="100" height="100" alt="" /> </a>'; $i++; if($i == 10) { echo '<br />'; echo '<br />'; $i = 0; } } echo '</div>'; PHP:
You could use something as the following: $perpage = 10; $currentpage = 0; $sql = "SELECT * FROM dogs"; $numRows = mysql_num_rows(mysql_query($sql)); $lastpage = ceil($numRows / $perpage); $getquery = mysql_query("$sql ORDER by ID LIMIT $currentpage, $perpage"); ... PHP: Also, the MySQL extension is deprecated as of PHP 5.5.0 so I strongly suggest you use PDO or MySQLi instead.
Hi, i got it to work but, i have a problem with how to switch pages, could you give an example of how i can switch from page 1 to 2 and so one and so on? Thank you very much for the help!
Let's say you have the page number in a GET parameter "page": // You can put this at the top $page = (isset($_GET['page'])) ? intval($_GET['page']) : 1; // and replace the $currentpage variable with this one $currentpage = ($page - 1) * $perpage; PHP: