piheshpi90 Posted January 27, 2011 Share Posted January 27, 2011 my coding is displaying all result in only one page.i want to limit it to 50result per page..can anyone give the suitable coding? right now,im using this <?php do { ?> <?php if ($totalRows_Recordset1 > 0) { // Show if recordset not empty ?> <tr bgcolor="#CCCCCC"> <td height="21"><div align="center"><span class="style17"> <?php $count=$count + 1; echo $count; ?> </span></div></td> <td><div align="center" class="style17"><?php echo $row_Recordset1['id']; ?></div></td> <td><div align="left" class="style17"><?php echo $row_Recordset1['name']; ?></div></td> <td><div align="center" class="style17"><a href="staf_info.php?id=<?php echo $row_Recordset1['id']; ?>"><img src="pic/b_view.png" width="16" height="16" border="0" /></a></div></td> <td><div align="center" class="style17"><a href="kemaskini_staf.php?id=<?php echo $row_Recordset1['id']; ?>"><img src="pic/b_edit.png" width="16" height="16" border="0" /></a></div> <div align="center" class="style17"></div></td> <td><div align="center" class="style17"><a href="staf_delete.php?id=<?php echo $row_Recordset1['id']; ?>"><img src="pic/b_drop.png" alt="padam" width="16" height="16" border="0" /></a><a href="staf_delete.php?id=<?php echo $row_Recordset1['id']; ?>"></a></div></td> </tr> <?php } // Show if recordset not empty ?> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> Quote Link to comment Share on other sites More sharing options...
Simon Mayer Posted January 27, 2011 Share Posted January 27, 2011 You should set this in your MySQL query, rather than your PHP You would need to use LIMIT to specify the maximum number of results (and an offset if you are doing a later page). At the end of your query, add something like ' LIMIT ' . $offset . ', ' . $limit You would have to define $offset and $limit by something else, such as $_GET attributes in the URL. Quote Link to comment Share on other sites More sharing options...
litebearer Posted January 27, 2011 Share Posted January 27, 2011 keyword - PAGINATION example of a free class I use, in action - http://www.nstoia.com/sat/disp_pag/ Quote Link to comment Share on other sites More sharing options...
piheshpi90 Posted February 1, 2011 Author Share Posted February 1, 2011 thank you so much for helping.i manage to view limited result lke i want. Quote Link to comment 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.