Jump to content

Help! Need to show files in database by date order on webpage


roytheboy

Recommended Posts

Hi there,

being a novice I am having problems showing files on my webpage in proper date order. They are stored in a mysql database.

 

I have stored the files in a table called filestore which has 5 columns:

 

ID = int column

StoryDate = Varchar column

fileName = Varchar column

mimetype = Varchar column

description = Varchar column

filedata = mediumblob column

 

The dates look like this: 8-November-2011, 21-March-2012 etc.

and when drawn from the database they are formatted by an external file 'date.php' to look like this: 08-11-2011, 21-03-2012 etc. I tried to order by date DESC.

Below is a snippet of the code:

 

// Default page view: lists stored files

 

$sql = 'SELECT id, filename, mimetype, storydate FROM filestore ORDER BY filestore.storyDate DESC, filestore.ID LIMIT 60';

$filelist = @mysql_query($sql);

if (!$filelist) {

  exit('Database error: ' . mysql_error());

}

?>

 

I wonder could the problem be that 'StoryDate' Varchar column is the wrong type? should it be Date or something else?

 

The webpage in question is here: http://www.sercweb.com

 

Any help greatly appreciated!

Roytheboy.

I guess as I am typing in the dates pertaining to the event instead of them being automatically generated I assumed this might be stored as text (Varchar)?

Thanks for pointing this out!

 

Would I have to input this in a particular format? I have been using eg. 12-November-2012

 

Please excuse the novice in me.

 

RTB

Archived

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

×
×
  • 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.