Unstoppable Domains โ€” AI Assistant

How to display certain amount of lines per page

SpaceshipSpaceship
Watch
Impact
0
Gentlemen,

I've a small MySQL table called USER.
Only 4 fields are in this table:
1. id -> smallint(6)
2. lastname -> varchar(30)
3. firstname -> varchar(30)
4. userid -> varchar(30)

I don't have problems to select all or a subset of the entries in this table.

My problem:
How do I display only a CERTAIN AMOUNT OF LINES per page SIMILAR to the solution provided in this forum - just go to "Web Design Forum" -> Programming, and all entries are displayed, but only a certain amount of entries PER PAGE. If you want to see the 2nd, 3rd etc. page, you only need to click on one of the numbers and the selected page is displayed.

It looks like this:

Pages (8). [1] 2 3 >> ... Last>>

QUESTION: can somebody point me to a TUTORIAL or to a piece of PHP-CODE which shows how to program this in PHP?

Looking forward to see some reponse ...
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
If your still in need of this... I can get some code wrote up for you tonight sometime. Let me know if your still in need of this...
 
0
•••
check out www.spoono.com under PHP snippets. There's code that will allow to you specify a # of characters and then it cuts it off there and adds '...'
 
0
•••
You add a limit to you're database query.

Code:
if ($_GET['limit'] == '') {
$limit = 0;
}
$limitend = $limit+50; //the number would be the number of entries per page
$sql = "SELECT * FROM user ORDER BY id LIMIT $limit, $limitend";
Then to display the number of pages, you get the total number of entries and divide it by the entries per page.
Code:
$pages = $totalpages/50;
if ($totalpages % 50 != '0') {
$pages++;
}
Now that you have your number of pages you just use a for loop and make a link for each page.
Code:
for ($page = 1; $page < $pages; $page++) {
Print "<a href=\"page.php?limit=$limitend\">$page</a>";
$limitend = $limitend+50;
}

I hope I understood correctly and I hope this helps.
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
Appraise.net
Spaceship
Domain Recover
CatchDoms
DomainEasy โ€” Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back