Jump to content

ORDER BY file modification time


skwap

Recommended Posts

I have a table in my database which stores lot of file names & file path. iam currently listing the files on the basis of its uploaded date (stored in databse) but  I want to list it on the basis of its file modification time.

How i can do it ??

my current sql statement is

 

$sql = mysql_query("SELECT * FROM `files` WHERE `cid` = '$types' ORDER BY `uploaded` DESC LIMIT $start,$limit");

 

anyone can help me ??

Link to comment
Share on other sites

Unless you create an automated process to interrogate the files and update the database with the file modified timestamp, you can't do this through a MySQL query. You will need to query the files, then when processing them add them to an array and at the same time get the modification time and add to the array as well. then you can order the array and finally output the data.

 

However, if this is for a pagination script, this will not help you since you need to have the order of the files so you can get the correct files for the page using LIMIT. In that case you can either create an automated process to continually read the files and update the database OR you will have to query ALL the records, determine their modification dates, order them - in PHP - then use PHP code to determine which ones are for the current page. Neither option is a very good one.

Link to comment
Share on other sites

can you tell me which function can i use to get proper file modification time ?

 

A simple google search for something like "php file modification" would tell you that. I love helping people, but when someone asks me to do something that they can easily do themselves I get peeved. :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.