mattm1712 Posted September 18, 2011 Share Posted September 18, 2011 i have done this code but i want to limit to 10 records per page, i cant get the start from and limint number on page correct, it only echos out the links, 1 and 2 i have 18 data inputs in my data base so that bit is corrent by its not echoing the data out please help i think the problem is im my query but cant put my finger on it <?php include 'connect.inc'; if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; }; $start_from = ($page-1) * 10; $result = mysql_query ("SELECT * FROM images ODER BY date ASC $start_from,10"); $num_rows = mysql_num_rows($result); echo $num_rows; ?> <table> <?php while ($row = mysql_fetch_assoc($result)) { ?> <tr> <td><? echo $row['title']; ?></td> <td><? echo $row['description']; ?></td> </tr> <?php }; ?> </table> <?php $rs = mysql_query("SELECT COUNT(id) FROM images"); $row = mysql_fetch_row($rs); $totalrecords = $row[0]; $totalpages = ceil($totalrecords / 10); for ($i=1; $i<=$totalpages; $i++) { echo "<a href='hello.php?page=".$i."'>".$i."</a> "; }; ?> thanks matt Quote Link to comment https://forums.phpfreaks.com/topic/247374-multiple-page-results/ Share on other sites More sharing options...
trq Posted September 18, 2011 Share Posted September 18, 2011 You have no LIMIT clause in your query. Quote Link to comment https://forums.phpfreaks.com/topic/247374-multiple-page-results/#findComment-1270398 Share on other sites More sharing options...
mattm1712 Posted September 18, 2011 Author Share Posted September 18, 2011 good point, plus i had spelt order wrong!! haha Quote Link to comment https://forums.phpfreaks.com/topic/247374-multiple-page-results/#findComment-1270399 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.