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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:01:42+00:00 2026-05-23T18:01:42+00:00

I have events (datetime) in my MySQL database. Days have 0, 1, or more

  • 0

I have events (datetime) in my MySQL database.
Days have 0, 1, or more events.

I want to show the upcoming 7 days, and below each day list the events happening that day (if any).

What would be the best practice to do so?

The easiest would be:

for(days) {
   for(mysql_query_get_events) {
      display_event
   }
}

but it would require to run the same big query for each day, and I believe this is very ineffective. How would you proceed?

  • 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-23T18:01:42+00:00Added an answer on May 23, 2026 at 6:01 pm

    Something along:

    SELECT * FROM events
        WHERE event_date > NOW()
            AND event_date < DATE_ADD(NOW(), INTERVAL 7 DAYS)
        GROUP BY date
        ORDER BY date ASC;
    

    This would select all events in the upcoming 7 days

    Edit: Just grab all events, loop through the days and keep popping results off the stack. E.g:

    events = sql_query()
    days = range(now, now + 7 days)
    
    for (day in days) {
        echo day
        while events[0].date = day {
            echo array_shift(events)
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL query below that I'm using to get events for my
I have a Location that can have Events. I want to have an upcoming_events
I have an events log database. I need to limit the size of SQL
I have a script that polls a MySQL database (Nagios, specifically) for the date/time
I'm trying to create google maps markers to show events, however I have the
I have a MySQL database with the following columns: id (INT) duration (FLOAT) start_date
Assuming I have table called events with the columns INT id DATETIME start_time DATETIME
I'm trying to do a many-many database select, where I have events and music
I have a mySQL table which contains events, details on the event, the event
Event 'start_time' is being stored incorrectly into mysql database. events that store incorrectly https://graph.facebook.com/112797205532177

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.