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

  • Home
  • SEARCH
  • 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 1074301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:06:21+00:00 2026-05-16T21:06:21+00:00

I am creating a blog post scheduling system using CodeIgniter. I want 10 posts

  • 0

I am creating a blog post scheduling system using CodeIgniter. I want 10 posts to show up a day. There is a field in the posts table named scheduled_date which I will get the posts that are less than or equal to the current date. When an admin user adds a new record to the database, I need an SQL statement that somehow will help me COUNT the number of records with the latest date in the database. For example:

// 9 records returned for the date 2011-01-01
$numbers_of_records == 9;
if($numbers_of_records == 10){
    // inserts record with `scheduled_date`='2011-01-01'
}else{
    // inserts record with the date latest date +1 day
}

How would I efficiently accomplish this?

Thanks

  • 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-16T21:06:22+00:00Added an answer on May 16, 2026 at 9:06 pm

    This will do the trick. It is simple and efficient.

    <?php
    
    //  It is very bad to have floating values, especially for settings
    //  it is good to use some sort of factory or settings class
    $maxDailyPosts = (int) SettingsFactory::getSettings()->get('maxDailyPosts');
    $date = '2011-01-01';
    
    //  Load # of post for data
    $numberOfRecords = (int) getNumberOfPostPerDate($date);
    
    //  Figure out the interval for increment
    $dayInterval = ($numberOfRecords >= $maxDailyPosts ) ? 1 : 0;
    
    //  
    $query = "INSERT INTO tbl (publish_date, ...) VALUES (DATE_ADD('$date', INTERVAL $dayInterval DAY), ...)";
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a custom item editor, and am using the following blog post
I am creating an online blog website and for each blog post, I'd like
I am using the following code (from a blog post) to resize an image
I'm creating a blog (and the rest of a website) using Python and Flask
So I'm trying to learn by creating a blog-engine. I'm using Hibernate with MySQL.
I am currently in the process of creating my own blog and I have
I'm thinking of creating a small offline blog editor for personal use and I
I'm creating a blog engine as a learning exercise and one particular problem has
I am creating a simple blog as part of a website and I am
I am a bit confused with this paticular blog post here... http://bartdesmet.net/blogs/bart/archive/2006/09/13/4417.aspx What is

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.