Jump to content

Recommended Posts

Hi,

I've got an image gallery where users can login and upload images. When an images is published it updates the "published" column with the current Unix timestamp

 

I want to be able to display the images on an archive page to view the uploads by month

 

Any ideas on how i should do this?

 

Here's my query string:

 

$query = "SELECT id, picture, user, title, published". 
         "FROM uploads". 
         "WHERE published is not null ".
         "ORDER BY published DESC ".  
         "LIMIT $offset, $rowsPerPage";

I really suck at dates myself.

 

If I understand you want to search for a given month? or loop through each month. If the latter, that's separate I think.

Either way, There are several ways I suppose but I would prolly determine the unix timestamp for the 1st day and last day of the month (midnight respectively) and add something like

"... WHERE field >= $monthstart AND field <= $monthend..."

 

 

That doesn't seem to work?

 

My dates are stored in my database as "1200350730" for example, which is 14/01/08

 

does the

WHERE MONTH(published) = $month

know this?

 

 

I've also tried with and without the DATE_FORMAT on the SELECT line

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.