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 6651327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:59:53+00:00 2026-05-26T00:59:53+00:00

I am creating a web app where if a user clicks on Link called

  • 0

I am creating a web app where if a user clicks on Link called “WEEK”, the page shows up all the posts which were submitted in that week. There’s also an option to view all the posts submitted this month. There’s a column in the posts table named post_date in which the date is stored in the format : YYYY-MM-DD.

My Problem: I don’t know how to generate the posts submitted this week and month.

I can successfully select the posts submitted on the current date like this:

$today = date("Y-m-d"); // This is the format of the DATE column named post_date in the posts table.
if($_GET['when'] == "today")
{
$when = $today;
}
else if ($_GET['when'] == "week")
{
$when = // I don't know what goes here if I want to generate posts submitted this week
}
else if ($_GET['when'] == "month")
{
$when = // I don't know what goes here if I want to generate posts submitted this month
}
// I have already connected to the database and selected the table.
$query = "SELECT * FROM posts WHERE post_date = '$when'";
$result = mysql_query($query);
// After this I Generate the Posts Using WHILE loop and mysql_fetch_array

If the $_GET[‘when’]’s value in the URL is “today”, the SCRIPT works fine and generates the posts submitted ‘today’. But I don’t know how to select the current week and the current month. I have already done my homework: I have googled and also searched StackOverflow for matching questions but there were questions like data from Last Week and the code was straight forward and couldn’t fit in my situation. For example, there was an option to select the 1st, 2nd, 3rd and 4th week by using WEEK($today,1) ( I don’t know if it works or not, but I want to generate the posts submitted in the current week and month ).

Thanks in advance.

  • 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-26T00:59:53+00:00Added an answer on May 26, 2026 at 12:59 am

    There are several MySQL functions that do things like this for you

    SELECT * FROM posts
    WHERE
       WEEK(post_date) = WEEK(CURDATE())
       AND
       MONTH(post_date) = MONTH(CURDATE())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I am creating a web app, that will give each registered user a
i'm creating a web app that's running on an Advantage Database server, not my
I am creating a web app which uses jQuery to authenticate: $.ajax({ url: /session/create?format=json,
I am working on creating a web app that will query event logs on
I am interested in creating a web app that uses JSP , Servlets and
I am creating a custom membership provider for a web app that already has
I am creating a web app that will use OpenID logins and OAuth tokens
I am creating a web app that uses Rails built-in helper functions to add
I am creating a scheduler web app that stores its data in a mysql
I have a web app that lets users create groups. On the front page

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.