Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-23-2005, 02:15 AM   #1
Registered: Feb 2004
Location: Sighisoara/Cluj-Napoca (Romania)
Distribution: CentOS 4, Fedora Core 6
Posts: 781

Rep: Reputation: 32
Paging data from XML with PHP


I'm writing some PHP code again and need to read some data from a XML file and display it on the screen. Is it possible to create some paging links? If yes, how? A link to a tutorial would be great too.
Paginating means for me this links like:
<Prev 1 2 3 4 [5] 6 ... 15 16 17 Next> Last>>

Thank you!
Old 03-23-2005, 09:57 AM   #2
Registered: Sep 2002
Location: Tulsa, OK
Distribution: Slack, baby!
Posts: 349

Rep: Reputation: 33
In order to provide page # links as you have described, your code will need to determine how many total pages exist (this totally depends on your code and what is being displayed, there is no rule of thumb to be applied here). once you know what constitutes a page, then you'll need to keep track of what page # where the user is located. If you know the current page and the total page, then the rest is fairly simple.

Given your example:
1. Are they on the first page? If not, print the <<first and <prev links. If so, skip them.
2. Loop through the pages, 1 to total_pages. if loop # == page_on #, then ignore the link portion and surround it with []'s.
3. Are they on the last page? If not, print the next> and last>> links. If so, skip them.

How you pass the current page number into the script via the URL, and how you determine the total # of pages, is your call.

Does this give you enough to go on?


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
onverting database rrelational data into xml using java anirudh Programming 0 03-23-2005 07:05 AM
PHP paging problem jojojo Linux - Newbie 1 02-24-2005 12:13 PM
PHP paging problem jojojo Linux - Newbie 2 02-22-2005 11:49 PM
PHP w/ XML ridertech Linux - Software 0 05-05-2004 02:50 AM
PHP and XML Bill Barrington Linux - Software 0 06-22-2003 08:08 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:29 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration