Jump to content

Show only Events from Current Date forward


muddy

Recommended Posts

Dear Freaks,

 

I've inherited a project and can't figure out the previous guys work.  On this page:

 

http://www.bananasinc.org/pgos.php

 

I'd like to make it so that events will only appear from todays date forward.  All events in the past will not appear.

 

Any help would be greatly appreciated and if I have to pay to get it done, so be it.

 

Here's the code for that page:

 

<?php
require("includes/connect.php");
require("classes/datum.php");
require("classes/chrono.php");
require("classes/pgo.php");
if (empty($thismonth)) {
$thismo = new Chrono("now");
$thismo->TimeZoneShift(-3);
$thismonth = $thismo->GetDT("datetime");
$thismonth = substr($thismonth,0, . "01 00:00:00";
} else {
$thismo = new Chrono($thismonth);
}
$tmo = intval(substr($thismonth,5,2)) - 1;
$tyr = intval(substr($thismonth,0,4));
if ($tmo == 0) {
$tmo = 12;
$tyr--;
}
if ($tmo < 10) $tstr = "0" . $tmo;
else $tstr = "" . $tmo;
$prevmonth = $tyr . "-" . $tstr . "-01 00:00:00";
$prevmo = new Chrono($prevmonth);
$tmo = intval(substr($thismonth,5,2)) + 1;
$tyr = intval(substr($thismonth,0,4));
if ($tmo == 13) {
$tmo = 1;
$tyr++;
}
if ($tmo < 10) $tstr = "0" . $tmo;
else $tstr = "" . $tmo;
$nextmonth = $tyr . "-" . $tstr . "-01 00:00:00";
$nextmo = new Chrono($nextmonth);
?>
<table width="100%" border="0" cellspacing="1" cellpadding="3">
                          <tr> 
                            <td width="75" bgcolor="#FFD000"><div align="center" class="pgl">Date</div></td>
                            <td width="75" bgcolor="#FFD000"><div align="center" class="pgl">Day</div></td>
                            <td width="75" bgcolor="#FFD000"><div align="center" class="pgl">Time</div></td>
                            <td width="175" bgcolor="#FFD000"><div align="center" class="pgl">Activity</div></td>
                            <td width="75" bgcolor="#FFD000"><div align="center" class="pgl">Where</div></td>
                            <td width="175" bgcolor="#FFD000"><div align="center" class="pgl">Sponsor/Contact</div></td>
                            <td width="75" bgcolor="#FFD000"><div align="center" class="pgl">Cost</div></td>
                          </tr>
					  
                         
					  
	<?php
		$q = "SELECT distinct a.ID,a.startDT FROM pgo a, pgo_dates b WHERE a.startDT>='2005-10-01 00:00:00' || (a.ID=b.pgoID && b.startDT>='2005-10-01 00:00:00') ORDER BY a.startDT ASC";
		//echo $q;
		$r = mysql_query($q) or DIE("Failure: " . $q);

		if (!mysql_num_rows($r)) {
			$q = "SELECT a.ID,a.startDT FROM pgo a WHERE startDT>='" . $thismonth . "' ORDER BY a.startDT ASC";
			$r = mysql_query($q) or DIE("Failure: " . $q);
		}

		for ($i=0;$i<mysql_num_rows($r);$i++) {
			$sdate = '';
			$sday = '';
			$stime = '';
			$pgo = new PGO(mysql_result($r,$i,"ID"));
			$mdates = $pgo->CKMultipleDates();
			$startDT = $pgo->startDT;
			$endDT = $pgo->endDT;
			$sMonth = $pgo->FormatChrono($startDT,"F");

			if (($startDT < $endDT) && (substr($startDT,0,10)<substr($endDT,0,10))) { //Start and End Date
				$sdate .= $pgo->FormatChrono($startDT,"F j");
				$sdate .= " to " . $pgo->FormatChrono($endDT,"F j");
			} else $sdate .= $pgo->FormatChrono($startDT,"F j"); //Just a Start Date

			$sday .= $pgo->FormatChrono($startDT,"D"); //1 Day

			$stime .= $pgo->FormatChrono($startDT,"g:i a"); //1 Day Start Time
			if (substr($endDT,11,5)>"00:00") {
				$stime .= " to " . $pgo->FormatChrono($endDT,"g:i a"); //1 Day End Time
			}
			$stime .= " ".$pgo->FormatChrono($startDT,"D");	


			if ($mdates) {
				$multipleDts = $pgo->getMultipleDates();
				//$sdate .= " & ";
				for ($x=0;$x<count($multipleDts);$x++) {
					$newMonth = $pgo->FormatChrono($multipleDts[$x]['startDT'],"F");
					$newDay = $pgo->FormatChrono($multipleDts[$x]['startDT'],"D");
					$newYear = $pgo->FormatChrono($multipleDts[$x]['startDT'],"Y");
					if ($sMonth == $newMonth) $sdate .= ", ".$pgo->FormatChrono($multipleDts[$x]['startDT'],"j");
					if ($sMonth != $newMonth) $sdate .= $pgo->FormatChrono($multipleDts[$x]['startDT'],"F j")." & ";
					if (isset($multipleDts[$x+1]['startDT'])) {
						if ($pgo->FormatChrono($multipleDts[$x+1]['startDT'],"F") !=$newMonth) $sdate .= $pgo->FormatChrono($multipleDts[$x]['startDT'],", Y & ");
					} //else $sdate .= $pgo->FormatChrono($multipleDts[$x]['startDT'],", F j");

					$sday .= "<br>".$newDay;

					$stime .= "<br>".$pgo->FormatChrono($multipleDts[$x]['startDT'],"g:i a"); //1 Day Start Time
					if (substr($multipleDts[$x]['endDT'],11,5)>"00:00") {
						$stime .= " to " . $pgo->FormatChrono($multipleDts[$x]['endDT'],"g:i a"); //1 Day End Time
					}
					$stime .= " ".$pgo->FormatChrono($multipleDts[$x]['startDT'],"D");				

					$sMonth = $newMonth;

				}
			}	


			if ($mdates) {
				$sdate .= ", ".$newYear;
			} else $sdate .= ", ".$pgo->FormatChrono($startDT,"Y");


		?>
        	   <tr valign="top" bgcolor="#FEF2B8"> 
               	<td width="75"><div align="center" class="pglSmall"><?php echo $sdate; ?></div></td>
                <td width="75"><div align="center" class="pglSmall"><?php echo $sday; ?></div></td>
                <td width="75"><div align="center" class="pglSmall"><?php echo $stime; ?></div></td>
                <td width="175"><div align="left" class="pglSmall"><?php echo $pgo->activity; ?></div></td>
                <td width="75"><div align="center" class="pglSmall"><?php echo $pgo->location; ?></div></td>
                <td width="175"><div align="left" class="pglSmall"><?php echo $pgo->contact; ?></div></td>
                <td width="75"><div align="center" class="pglSmall"><?php echo $pgo->cost; ?></div></td>
               </tr> 
	<?php


		}
		if (!mysql_num_rows($r)) {
	?>
     	  
		   <tr bgcolor="#FEF2B8"> 
               	<td colspan="7"><div align="center" class="pglSmall"><b>No Professional Growth Listings currently listed.</b></div></td>
               </tr>

	<?php
		}
	?>				  
                        </table>

$q = "SELECT distinct a.ID,a.startDT FROM pgo a, pgo_dates b WHERE a.startDT>='2005-10-01 00:00:00' || (a.ID=b.pgoID && b.startDT>='2005-10-01 00:00:00') ORDER BY a.startDT ASC";

 

I'd say you need to edit that line so thatyou use today's date instead of 2005-10-01

Thanks for the reply Andy,

 

How would I edit this line

 

$q = "SELECT distinct a.ID,a.startDT FROM pgo a, pgo_dates b WHERE a.startDT>='2005-10-01 00:00:00' || (a.ID=b.pgoID && b.startDT>='2005-10-01 00:00:00') ORDER BY a.startDT ASC";

 

so that the listings show up only from today's date on (not today, as in this exact today, but any "today" = the current today).

 

Thanks again

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.