[advanced search]
Results from the most recent live auction are here.
22 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Domain Name Industry Newsletter
Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 12-01-2003, 04:57 AM   · #1
Billard
New Member
 
Trader Rating: (0)
Join Date: Nov 2003
Posts: 6
NP$: 10.00 (Donate)
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:

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 ...


Please register or log-in into NamePros to hide ads
Billard is offline   Reply With Quote
Old 01-01-2004, 02:02 PM   · #2
CreativeLogic
NamePros Regular
 
CreativeLogic's Avatar
 
Name: Ryan Amos
Trader Rating: (15)
Join Date: Sep 2003
Posts: 893
NP$: 18.00 (Donate)
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   Reply With Quote
Old 01-02-2004, 06:51 PM   · #3
Jeanco
RyanPrice.ca - Developer
 
Name: Ryan Price
Trader Rating: (28)
Join Date: Dec 2003
Posts: 1,331
NP$: 34.00 (Donate)
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   Reply With Quote
Old 01-05-2004, 01:05 AM   · #4
PhreakShow
New Member
 
Name: Dylan Hall
Location: Pennsylvania, USA
Trader Rating: (0)
Join Date: Jan 2004
Posts: 7
NP$: 50.00 (Donate)
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.
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   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
RealTechNetwork Hunting Moon Arcade Script
Advertise your business at NamePros
All times are GMT -7. The time now is 10:01 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0