NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page How to display certain amount of lines per page

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search
5 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 12-01-2003, 03:57 AM THREAD STARTER               #1 (permalink)
New Member
Join Date: Nov 2003
Posts: 6
Billard is an unknown quantity at this point
 



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 ...
Billard is offline  
Old 01-01-2004, 01:02 PM   #2 (permalink)
NamePros Regular
 
CreativeLogic's Avatar
Join Date: Sep 2003
Posts: 889
CreativeLogic has a spectacular aura aboutCreativeLogic has a spectacular aura about
 



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 :)
CreativeLogic is offline  
Old 01-02-2004, 05:51 PM   #3 (permalink)
RyanPrice.ca - Developer
Join Date: Dec 2003
Posts: 1,328
Jeanco is a jewel in the roughJeanco is a jewel in the roughJeanco is a jewel in the rough
 



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
Jeanco is offline  
Old 01-05-2004, 12:05 AM   #4 (permalink)
New Member
Join Date: Jan 2004
Location: Pennsylvania, USA
Posts: 7
PhreakShow is an unknown quantity at this point
 



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.
????: 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;
}
I hope I understood correctly and I hope this helps.
PhreakShow is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 02:08 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger