pagination of .txt files in php

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
moisea
Forum Newbie
Posts: 13
Joined: Wed Nov 01, 2006 2:29 pm

pagination of .txt files in php

Post by moisea »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hi, i would like to know how to get the a php pagination for txt files as shown below

Code: Select all

<?php 
$filename="mycontent.txt";
$fp=fopen ($filename, "r") or die ("Couldn't open $filename");
while (! feof ($fp))
	{ 
	$line = fgets ($fp, 1024);
	print "$line<br>";
	}
?>
i need a php pagination please, as i have about 7 .txt files to display on different pages.
any ideas on how to get this sorted?
many thanks for having a look.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

http://www.timvw.be/pagination-for-all has also an example where the contents of .bashrc file are paginated...
moisea
Forum Newbie
Posts: 13
Joined: Wed Nov 01, 2006 2:29 pm

Post by moisea »

hi tim great tut, however i am running thru some trouble now. send you an email through the link you gave me. many thanks again.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

Just an observation...

But files listed as paginated results...is probably the one and only time you *don't* want to paginate results...ergonomically most people (myself included) expect files to be listed completely...any pagination is usually handled implicitly through directories/folders which the user creates...

Cheers :)
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Hockey wrote:But files listed as paginated results...is probably the one and only time you *don't* want to paginate results...ergonomically most people (myself included) expect files to be listed completely...any pagination is usually handled implicitly through directories/folders which the user creates...
So why does Unix have the 'more' command (eg ls -a | more )? ;)

Paging through things is always a good idea if you have a long list. You should be able to sort, search, filter, and control the number of items returned too. For everything. Even files.
User avatar
theFool
Forum Newbie
Posts: 17
Joined: Thu Oct 26, 2006 2:00 am
Location: Berlin, DE

Post by theFool »

I would say, it depends on the amount of files. Having more then... maybe 500... files on one page, would somehow scare me.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

onion2k wrote:
Hockey wrote:But files listed as paginated results...is probably the one and only time you *don't* want to paginate results...ergonomically most people (myself included) expect files to be listed completely...any pagination is usually handled implicitly through directories/folders which the user creates...
So why does Unix have the 'more' command (eg ls -a | more )? ;)

Paging through things is always a good idea if you have a long list. You should be able to sort, search, filter, and control the number of items returned too. For everything. Even files.
Thats a good point... :P But I've yet to see a GUI file explorer that paginated results??? Obviously it's possible...but my point was that for files at least, it's going against common convention...from what I've experienced.

Of course I don't exactly tinker with file managers all to much...so what do I know :)
moisea
Forum Newbie
Posts: 13
Joined: Wed Nov 01, 2006 2:29 pm

Post by moisea »

that's exactly what is happening in my case Hockey, i have a folder that holds just under 10 files which i am trying to paginate. i am still working on it though...
Post Reply