|
| Register now to interact with over 11,000 members! Registered users have Posting Privileges, free access to Private Messaging, Email Notifications and more. |
|
|||||||
![]() |
|
|
Thread Tools |
|
|
#1 |
|
Guest
Posts: n/a
|
filedate and prev - next
1) I guess there is possible to extract filedate(last updated), but by which command?
2) In a script I run a foreach loop giving me a list of items. I'd like to limit the listing to the last 10, and add following functions... prev 10 | all |and next 10 ( if count($i)>count($i)-10 ) Any allready made willing to share? regs |
|
|
#2 |
|
Go Blue!
Join Date: May 2002
Location: OH, USA
Posts: 143
Reputation: 7
|
1) try the filemtime function in PHP.
PHP Code:
__________________
Rob |
|
|
|
|
#3 |
|
foo
Join Date: Jan 2003
Location: Seattle-ish
Posts: 2,597
Reputation: 106
|
2) Search for pagination on phpbuilder.com/board or google. It's been beat to death too many times to repost here.
__________________
webhead.cc |
|
|
|
|
#4 |
|
Guest
Posts: n/a
|
thx rh0926!
For the pagination.... I found 1000 for MySQl but none for flatfile... I'guess this can be re-written some to work... Bellow is modifed pagination script for MySQL... I'd like to make this work for a flatfile... As it is it will no print out the wanted result... as it seems to be a list and definition issue: PHP Code:
|
|
|
#5 |
|
Guest
Posts: n/a
|
I guess the script was to long to get the attention, so I narrow the problem down to the actual loop...
PHP Code:
e.g Total number of data entries = 13 Limit per page is = 5 This gives the correct number of pages <prev| 1 2 3 |next> but page 1 displayes 15 queries (1-13) page 2 displayes 8 queries (6-13) page 3 displayes 3 queries (10-13) it is suppose to display page 1: 1-5 page 2: 6-10 page 3: 11-> |
|
|
#6 |
|
Just tryin' to help
Join Date: Jan 2003
Location: along the journey
Posts: 8,036
Reputation: 125
|
It is doing what you asked:
while ($i <= $totalRowsNum) { You need to ask for not <= the total number of rows, but to the next page (+5). Should be: while ($i <= ($thisOffset + $lmitperpage)) { note - I did not search the script for the correct variable name for limit per page, but you get the idea. It really is a little bit harder than that, because you should check to make sure you do not run over the total rows, but you can figure that out I am sure. If $thisOffset + $lmitperpage is > total rows then use total rows.
__________________
Enhance your PowWeb experience @ B&T's Tips & Scripts Got some free time? You can find Nothing of Value @ PrettyWorthless.com |
|
|
|
|
#7 |
|
Guest
Posts: n/a
|
thx a lot B&T !
It is allways so obvious.... Now it works as intended.... Anyone in need of a working version of pagaination for flatfiles just notify me! If you like I can mail you the complete script B&T for your script collection at your site... regs |
|
|
#8 |
|
Just tryin' to help
Join Date: Jan 2003
Location: along the journey
Posts: 8,036
Reputation: 125
|
Now that you have it running . . . there is a more efficient way to deal with date ordered flat files.
If you name the files with the unix date, then you can read the directory names into an array (not the data, just the file names). That is very fast and consumes little resources. Then you sort the array of file names (the dates) how you want. Then do the processing on the array to determine what to show (your page processing). Then in processing you use the array values to read ONLY the 5 that will show on the page. Not a big deal with 18 files, but much more efficient if you have 100's. Would cause you to change: 1) Your file naming convention. 2) The initial read to read the directory and not files. 3) In the print a page routine you would read the files to be displayed as you need them. This works very well for me. Is very fast. And is friendly to Powweb's servers ![]()
__________________
Enhance your PowWeb experience @ B&T's Tips & Scripts Got some free time? You can find Nothing of Value @ PrettyWorthless.com |
|
|
![]() |
| Thread Tools | |
|
|