List upcoming events only

24 posts by 7 authors in: Forums > CMS Builder
Last Post: February 24, 2015   (RSS)

Hi

Is there any way to list the next upcoming event only.  I have a series of events, and am using the "date" field, but how would I get upcoming date only, not dates that have already passed?

I know that

 // load records from 'upcoming_events'
  list($upcoming_eventsRecords, $upcoming_eventsMetaData) = getRecords(array(
    'tableName'   => 'upcoming_events',
    'limit'       => '1',
    'loadUploads' => true,
    'allowSearch' => false,
  ));

but haven't found anything on the forum to only show forthcoming dates.

Any ideas?

Thanks

Hey degreesnorth,

You just need to add a where statement that tells your getRecords function to return records that are greater than the current date:

//Get current date 1 second before midnight 
$today = date('Y-m-d 23:59:59');


 // load records from 'upcoming_events' that have a date greater than 1 second before midnight today.
  list($upcoming_eventsRecords, $upcoming_eventsMetaData) = getRecords(array(
    'tableName'   => 'upcoming_events',
    'where'       => "`date` > '$today'", 
    'limit'       => '1',
    'loadUploads' => true,
    'allowSearch' => false,
  ));

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Perfect, thanks so much.

By proba - February 13, 2015

Hello,

just want to ask is it possible to show results only from next seven days based on only date field. I mean today + next seven days only with date field?

Cheers

By proba - February 16, 2015

Is there anybody here who can help me with this?

By claire - February 16, 2015

Hi there - yes, you can change the where clause to something like this:

<?php
    list($e_blast_events_noticeRecords, $e_blast_events_noticeMetaData) = getRecords(array(
    'tableName'   => 'e_blast_events_notice',
      'where' => 'date <= ((NOW() + INTERVAL 7 DAY) AND date >= NOW()',  
      ));  
      
    ?>

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By proba - February 16, 2015

i got this error - "MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY dragSortOrder' at line 4"

By claire - February 16, 2015

I'm afraid you can't use this as is - it needs to be adjusted for your particular sections. Can you show me exactly what your getRecords query looks like?

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Hello. Can you give me the 'where' statement if I need to show Listings from the current date to the last 7 days previously posted?

So I need to show the last 7 days Listings up until the current date. Thank you.