Page 1 of 1

SQL call for future Events

Posted: Thu Oct 29, 2009 2:49 pm
by hoben
I am designing a dynamic webpage that uses a SQL DB to call events... It works in the fact that it calls and displays all the events. Now I am trying to filter it so it only shows the events that are in the future. I have put a PHP clock on the site and can call the current time/date in variable and put it where ever. My thought was to then use an IF statement that would compare event.eventEnd (field of ending time of event in YYYY-MM-DD 00:00:00 format) to $gDate (current Time/Date in UNIX Seconds format). I also selected the event.eventEnd from the DB in UNIX_TIMESTAMP so they would be in the same format. I can display both numbers on the page with the repeating do {} loop but I can't figure out where and how to put the IF statement...

the site as is is upon a test site and can be viewed at http://www.osheaslouisville.net/test

Code: Select all

<?php do {
 
<p align="center" class="happeningsall">
     <?php echo $gDate?><br />
     <?php echo $row_rsToday['UNIX_TIMESTAMP(event.eventEnd)']?></p>
<p align="center">
   <span class="happenings_location">
       <a href="event_descriptions.php?eventID=<?php echo $row_rsToday['eventID']; ?>" target="_parent">
       <?php echo $row_rsToday['locationName']; ?></a></span>
       <a href="event_descriptions.php?eventID=<?php echo $row_rsToday['eventID']; ?>" target="_parent"><br />
          <span class="happeningsall">
       <?php echo $row_rsToday['eventName']; ?><br />
       <?php echo date('D, m/d/Y',strtotime($row_rsToday['eventStart'])); ?></span></a>
           <span class="happeningsall"></span><br /><br />
  <img src="images/divider.jpg" width="82" height="6"/><br /></p>
   <?php   } while ($row_rsToday = mysql_fetch_assoc($rsToday)) ; ?>

Re: SQL call for future Events

Posted: Fri Oct 30, 2009 1:49 pm
by akuji36
Hello

Mysql has an interval function that may help you out:

http://dev.mysql.com/doc/refman/5.0/en/ ... tions.html

thanks

Rod

Re: SQL call for future Events

Posted: Tue Nov 03, 2009 4:41 pm
by hoben
That sir worked great... I didn't want anything in the past so I took the INTERVAL down to 0 DAYS and it only calls future events... Thanks I was banging my head for what I'm certain people thought was an easy answer...

Can't thank you enough!!
Greg

Re: SQL call for future Events

Posted: Wed Nov 04, 2009 8:57 am
by akuji36
Glad I could help .

Php has another way to show time in past and future

must use an offset: follow this link to video tutorial

by Alex at phpacadmey:

http://www.youtube.com/user/phpacademy# ... 8OQMwhdI5M

thanks

Rod