Jump to content

how to limit number of result per page


piheshpi90

Recommended Posts

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)); ?>

Link to comment
https://forums.phpfreaks.com/topic/225821-how-to-limit-number-of-result-per-page/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.