Reputation: 487
Following is the code for my table:
<table class="user_details">
<tr>
<th> User ID </th>
<th> Name </th>
<th> Address </th>
<th> Email </th>
<th> Status </th>
</tr>
<tr>
<? foreach($user_data as $key){
echo "<tr>";
echo "<td>".$key['id']."</td">;
echo "<td>".$key['name']."</td">;
echo "<td>".$key['adress']."</td">;
echo "<td>".$key['email']."</td">;
echo "<td>".$key['status']."</td">;
echo "</tr">;
}
?>
</table>
Now there are more then 50 records which are coming in the above mentioned code. Is it possible through jQuery that I show only 10 records at a time and have the next and previous buttons over there. I don't want to use any external plugin. What could be the possible ways?
Upvotes: 0
Views: 1337
Reputation: 431
No external plugin?? Then you have to keep a track of what is the current record range displayed on page (Example: 1-10 or 10-20) and then on clicking previous or next you will have to send query to db asking for next set of records or filtering the record with those that fall in the range. Some dbs allow sql to specify the range of records you interested in discarding others. So you see it is a bit of programming that you will have to do.
Upvotes: 0
Reputation: 3611
If you don't want to use external plugins, you have to do it by hand: show/hide the rows, add extra buttons to navigate, etc.
But I would suggest you to load only the data you want to display using an ajax call instead of writing all the rows.
Upvotes: 0