no404 Posted May 15, 2006 Share Posted May 15, 2006 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"? Quote Link to comment Share on other sites More sharing options...
.josh Posted May 15, 2006 Share Posted May 15, 2006 well if you have a time/date type column and have it autoupdate every time a row is updated, you can always do likeselect * from table order by timecolumn desc limit 30require 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] Quote Link to comment Share on other sites More sharing options...
no404 Posted May 15, 2006 Author Share Posted May 15, 2006 Uh, sorry, but I didn't quite understandish that column/row thing. But i got the include vs request, thx:) Quote Link to comment Share on other sites More sharing options...
.josh Posted May 15, 2006 Share Posted May 15, 2006 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. Quote Link to comment Share on other sites More sharing options...
no404 Posted May 15, 2006 Author Share Posted May 15, 2006 Think i got that one;) Will it be easier to sort them after filename, and show the 30 first? Quote Link to comment Share on other sites More sharing options...
.josh Posted May 15, 2006 Share Posted May 15, 2006 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.