Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6781529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:38:04+00:00 2026-05-26T16:38:04+00:00

BACKGROUND: I’m currently working on building a photography gallery where I release a new

  • 0

BACKGROUND: I’m currently working on building a photography gallery where I release a new image every 2 hours. As I process and upload each image and store their information in the database, I run a check to see if I currently have images queued for future release. This check is exemplified below.

$last_added = mysql_query("SELECT date FROM images ORDER BY date DESC");
$last_added = mysql_fetch_row($last_added);
$last_added = strtotime($last_added[0]);
    if($last_added < time() - 7200):
        $time = time();
    else:
        $time = $last_added + 7200;
    endif;

$timestamp = date( 'Y-m-d H:i:s', $time );

mysql_query("INSERT INTO images (name,date,artist,tags,id) VALUES ('".$name."','".$timestamp."','".$artist."','".$tags."','".$id."')");

Basically it grabs the image with the highest date and checks to see if it is in the past or in the future. If it’s in the past, it tags the newest image with the current timestamp, if it is not in the past, it tags the newest image with a timestamp 2 hours after the highest image already in the database.

I have it set that way because I don’t have time to add new images every single day and this allows them to be time released keeping the site alive and updated while I am away.

QUESTION: However, when I do have time, I would like to add more images and instead of having them be added 30 days in the future, I would like to decrease the interval from 2 hours to 1 hour…then possibly from one hour to 30 minutes, etc.

Is there a convenient way to first check the highest dated image (like perhaps today + 30 days), and then have it check to begin filling in the interval gaps so that if the highest timestamp meets our criteria the next image added will get added 1 hour after the next image that is about to be released (filling the gap between it and the one that would be released 2 hours later). Then the image after that would be added 1 hour after the second future queued image filling that interval gap, etc.

The goal is that I can just keep tagging and adding images and it automatically keeps me queued for the future and automatically decreases the interval based on how far into the future I’m already queued up.

If I’ve not been specific enough, please let me know. I’m happy to clarify if needed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:38:05+00:00Added an answer on May 26, 2026 at 4:38 pm

    Sure. Here’s what I would do:

    First, create two columns… an “added” datetime, and a “posted” datetime.
    Added would be the datetime you put them in your database, and posted would be the datetime they appear live in a post on your site.

    Determine a minimum and maximum number of images to post per day. So if you had a minimum of 1 per day, and a maximum of 12, you want your script to consider 7 days in advance, and you have 90 images ready to go, then you want the script to place 84 images, one every 12 hours. If instead you had 42 images ready, the script would place all 42, at an interval of 4 hours. If instead you only had 3 images ready, the script would place 3 at an interval of 1 day apart each. Make sense?

    Create a script that runs in a cron job every hour or so… whatever you feel is necessary. In this script do the following:

    1. SELECT COUNT(*) FROM images WHERE added IS NULL; (This determines how many images haven’t been placed that you have to work with.)
    2. SELECT MAX(posted) FROM images; (This determines the last time we posted an image.)
    3. Next, we figure out the time between image. Using my example parameters, this is (7/imagecount)*24. If this is greater than 24 (meaning, 24 hours per image) then, we use 24. If this is less than 2 (meaning, 2 hours per image), then use 2 instead.
    4. Take the time between each image, and determine if enough time has passed since the last time we posted an image.
    5. If it has, UPDATE images SET posted=NOW() WHERE id=12345. Otherwise, do nothing.
    6. End of script.

    So, this script will run every hour, and check if it is time to post a new image. If it isn’t, it does nothing. If it is, it will post only one. On the next hour, it will recalculate, thus factoring in any new images or conditions.

    I hope this flow makes sense. There are undoubtedly other ways to solve this problem, but I think this is closest to what you are looking for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: We're building an application that allows our customers to supply data in a
Background I am working with a monad built of a stack of transformers one
Background I'm working on an application for my own needs, with some very lightweight
Background: My current working environment involves many navigation links that constantly updates, but the
Background info: Me and a couple of friends are building this platform game in
Background We currently use OpenID for authentication of users, and use the Claimed Identity
Background info: We are currently 3 web programmers (good, real-life friends, no distrust issues).
Background: I'm new to CakePHP. I have a small test site (mostly composted of
Background I first wanted to upload a file via json and get a response
Background: I'm working through the Programming Collective Intelligence book by Toby Segaran; specifically the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.