table limit

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

table limit

Post by jayson.ph »

hi all,

i have table and it have a thousand of rows or data and to make it net and clear to a user, i put a limit in 100 as row. but how can i do to view other data?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: table limit

Post by Celauran »

Pagination. Use an offset with your limit.

Code: Select all

$limit = 100;
$offset = ($_GET['page'] - 1) * $limit;
$query = "Blah blah whatever LIMIT $offset, $limit";
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

Re: table limit

Post by jayson.ph »

Thank for this and where should i put this code as you show up above.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: table limit

Post by pickle »

It's probably best if you do some research on the concept of pagination, as it's generally a larger concept than is suitable for a forum post.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
mekha
Forum Contributor
Posts: 112
Joined: Sat Mar 31, 2012 6:50 am

Re: table limit

Post by mekha »

Thank for this and where should i put this code as you show up above.

If it is a paging,you can put it in the top of the page , for example:

Code: Select all

<?php
//any code
?>

<html>
<head></head>
<body></body>
</html>

But!!
if your code is include loops or something like loop(foreach,for,while..exc..) you must put it in the right place , In the top of the page(like the previous example) or any place that match your full code!...
i wish i helped you,if not,,someone else may help you :D
Post Reply