Jump to content

Archived

This topic is now archived and is closed to further replies.

no404

List # last edited?

Recommended Posts

Is it possible to include the (let's say) 30 last edited files? And how? I tried the libraries. but couldn't find anything=/ And btw, what's the difference between "include" and "require"?

Share this post


Link to post
Share on other sites
well if you have a time/date type column and have it autoupdate every time a row is updated, you can always do like

select * from table order by timecolumn desc limit 30

require vs. include:

from the manual:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Unlike include(), require() will always read in the target file, even if the line it's on never executes. If you want to conditionally include a file, use include(). The conditional statement won't affect the require(). However, if the line on which the require() occurs is not executed, neither will any of the code in the target file be executed.
[/quote]

Share this post


Link to post
Share on other sites
Uh, sorry, but I didn't quite understandish that column/row thing. But i got the include vs request, thx:)

Share this post


Link to post
Share on other sites
oh wait, you mean like files. for some reason i saw rows (as in, database table rows) instead of files. silly me.

use [b]scandir[/b] to retrieve an array of the files, then loop through each array element with a [b]foreach[/b] or a [b]while[/b] loop and use [b]filemtime [/b] to get the time modified. Also, inside the loop, make an array of the times, and then sort the array with[b] rsort[/b] to sort them greatest (most recent) to least (oldest) and finally, do a [b]for[/b] loop that counts to 30, echoing the values, or whatever you want to do with them.

Share this post


Link to post
Share on other sites
Think i got that one;) Will it be easier to sort them after filename, and show the 30 first?

Share this post


Link to post
Share on other sites
yes. you are going to have to retrieve the last modified dates with [b]filemtime[/b] before you can figure out which ones were modified the soonest.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.