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.

Link to comment
Share on other sites

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

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.