| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| New Member Join Date: Nov 2003
Posts: 6
![]() | How to display certain amount of lines per page 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: ????: NamePros.com http://www.namepros.com/programming/15709-how-display-certain-amount-lines-per.html 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 ... |
| |
| | #2 (permalink) |
| NamePros Regular Join Date: Sep 2003
Posts: 889
![]() ![]() | 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...
__________________ Online Time Tracking :) |
| |
| | #3 (permalink) |
| RyanPrice.ca - Developer Join Date: Dec 2003
Posts: 1,328
![]() ![]() ![]() | 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 '...'
__________________ Ryan Price - Webmaster www.HostDurham.com - For Hosting | www.jeanco.ca - For Webdesign |
| |
| | #4 (permalink) |
| New Member Join Date: Jan 2004 Location: Pennsylvania, USA
Posts: 7
![]() | 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"; Code: $pages = $totalpages/50;
if ($totalpages % 50 != '0') {
$pages++;
} ????: NamePros.com http://www.namepros.com/showthread.php?t=15709 Code: for ($page = 1; $page < $pages; $page++) {
Print "<a href=\"page.php?limit=$limitend\">$page</a>";
$limitend = $limitend+50;
} |
| |