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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.