Closed Thread Icon

Topic awaiting preservation: Messages per page - PHP (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=11970" title="Pages that link to Topic awaiting preservation: Messages per page - PHP (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Messages per page - PHP <span class="small">(Page 1 of 1)</span>\

 
u-neek
Bipolar (III) Inmate

From: Berlin, Germany
Insane since: Jan 2001

posted posted 12-29-2001 11:37

Hi,

I have some text files with the UNIX-Timestamp in the name (1007525758.txt). I read them into an array and sorted them in the correct order. Now i want to display the content from every text-file. But not every file on one page. I want to limit the messages per page (for example 15 messages per page). And i want to link to the previous and next page.

I know how to do that with MySQL, but what about flat text files?

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 12-29-2001 11:47

PHP?

Assuming that your files don't suddenly change (ie, new ones added...) you could put them in an array, and then display for example only 16-30 out of that array...

example:
$myfileArr = //put whatever you use to get a list of the files here, make sure it is sorted.

function display_files($firstToDisplay,$fileArray) {
for ($i = $firstToDisplay, $i < ($firstToDisplay + 15),$i++) {
if ($i > count($fileArray) {break;}
print($fileArray[$i]); //put the file here. just outputing the name for demonstration purposes.
} //of for ($i = $firstToDisplay)
} //of function display_files

display_files(1,$myFileArr);
all you have to do now is make a script, that calls this function with the appropriate variables. Ie make sure that it shows a link that passes a new value for the $firstToDisplay.
Oh and that code could use some additional error checking.

hope this helps,

Tyberius Prime

u-neek
Bipolar (III) Inmate

From: Berlin, Germany
Insane since: Jan 2001

posted posted 12-29-2001 11:55

Ok, ok, ok. I'm stupid... To lazy to activate my own brain.

Thanx Tyberius Prime.

« BackwardsOnwards »

Show Forum Drop Down Menu