Ok, so here is my problem. I have a bunch of events in a database that I am trying to call. Each event has a start date and and end date. Some events are only on 1 day so their start date and end date are the same. Therefore some dates look like this...
Jan 25-27
and others only have one day like this..
Feb 26
My problem is that i am trying to do a couple things (see below) based on whether or not the end date is > than the start date. The problem is that something happens in the loop i am running screwing up the if conditionals.
You can see the output on the front end here.
http://dev.usta.org/eventHome.php?urh=home.eventHome
Problem is that for the second event the date is in the DB as just feb. 26 (not 26-27). if I take out that first event in Jan. the second one is fine, so I think it has something to do with the variables and the if statements, but I can not figure this out for the life of me. Any Help?
that
Code: Select all
<?php
// Set Row Color
$color1 = "#ffffff"; $color2 = "#efefef";
$row_count = 0;
$arr_events = getTopXForPageType( 100, "events", "eventDateStart asc, nickname asc" );
for( $i=0; $i < count($arr_events); $i++ ) {
$page = getPageContent( "", $arr_events[$i], 0 );
$eventDateStart = $page["eventdatestart"];
$eventDateEnd = $page["eventdateend"];
$city = $page["city"];
$state = $page["state"];
$filename = $page["filename"];
$pagename = $page["pagename"];
$nickname = $page["nickname"];
$eventTime = $page["eventtime"];
$eventLocation = $page["eventlocation"];
if ($eventDateEnd > $eventDateStart) {
$formatDateStart = date('M j', strtotime("$eventDateStart"));
$formatDateEnd = date('j', strtotime("$eventDateEnd"));
$hyphen = "-";
} else {
$formatDateStart = date('M j', strtotime("$eventDateStart"));
}
if ( strlen( trim( $city ) ) > 0 ) {
$comma = ",";
} else {}
// Alternate Row Color
$row_color = ($row_count % 2) ? $color1 : $color2;
print "<tr bgcolor=$row_color>
<td valign=top width=80>
$formatDateStart$hyphen$formatDateEnd
</td>
<td valign=top>
<a href="" . $filename . "?urh=home.events." . $pagename . "">" . $nickname . "</a><br><br></td>
<td valign=top width=190>$eventTime$eventLocation<br>$city$comma $state</td>
<td valign=top width=85>Register Now!</td>
</tr>";
// Add 1 to the row count
$row_count++;
}
?>