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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:49:59+00:00 2026-06-02T14:49:59+00:00

I have an events list created with php/mysql which displays up and coming events

  • 0

I have an events list created with php/mysql which displays up and coming events in the next 14 days. The db has 8 fields

event_ID,
date_1,
date_2,
eventTitle,
eventDetails,
location,
publish,
updated.

I have created a list using this sql statement

SELECT gpe.*, gpr.name 
FROM growl_presevents gpe, growl_presrail gpr 
WHERE gpe.location LIKE gpr.railID AND (date_1 >= '$today' AND date_1 <= '$week') 
AND gpe.publish = 'y' 
ORDER BY date_1 ASC

The arrays are filled by these statements

$today = date('Y-m-d');                     /// Todays date

$week = date('Y-m-d', time() + (86400*14)); /// Todays date + 14 days

The list is fine, but I need a tweak so that an event is displayed if it lasts for more than one day, and the date_1 is outside the 14 day period.

e.g. (just example data not actual)

if today is 2012-02-01

date_1      date_2      location   Title         details

2012-02-07  NULL        Loc001     Show          Stage show

2012-02-13  2012-02-18  Loc002     Open Air      Festival

2012-02-17  NULL        Loc001     Comedy        Comedy Show

Using my SQL query above, the first two dates would show ‘$today’, on the ‘3rd’ all three would be displayed, then on the ‘8th’ the first row would disappear. All OK so far, but this is where I need help. Using this query on the ’14th’ row 2 would disappear, but the event is on until the 18th, therefore I want it to still display until the 18th.

There is probably an easy way of doing this, but I have not been able to fathom it out, so any help would be much appreciated.

Thanks

Phil

  • 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-06-02T14:50:03+00:00Added an answer on June 2, 2026 at 2:50 pm

    Try this

    SELECT gpe.*, gpr.name  
    FROM growl_presevents gpe, growl_presrail gpr  
    WHERE gpe.location LIKE gpr.railID 
    AND (
        (date_1 >= '$today' AND date_1 <= '$week')
        OR (ISNULL(date_2,0) >= '$today' AND ISNULL(date_2,0) <= '$week')
        )  
    AND gpe.publish = 'y'  
    ORDER BY date_1 ASC 
    

    So basically do the same check on date_2 as you do on date_1 as an OR. Use ISNULL to provide 0 if a NULL date is found.

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

Sidebar

Related Questions

I have a dynamically created list that displays radio buttons next to it. When
I'm creating a website(PHP + MySQL based) with a list events. I currently have
I've created a simple 'favourites' system in my django app. I have events which
I have a list of events that I wish to store the starting and
In my ASP.NET Web-form Project I have an Event which Export Data ( List<Profit>
i have bookings table which has two people- i want to return person_1 as
I had a mysql table called events with the fields: id, date, and name.
I have me a socket created in PHP that I am connecting to in
unexperienced mysql user here :) I have 2 tables One holds a list of
I am building an order form with PHP and MySQL. The PHP Form has

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.