I am using this as a calendar of events widget.
Each thread title I want to find is formatted as MM/DD/YYYY - description of an event.
These threads have a thread prefix tag of chapter_event or other.
The threads are sorted by title and an extra <br /> is placed between titles each time the month changes.
The problem is that I want to find thread titles that begin with today and the future.
I thought if I formatted a variable $today that I could compare it to the first 10 characters of the title string. This does not work. I can find the first 2 characters to omit previous months. I could also omit last year. But when I look for posts that are after today's day, previous posts are omitted.
Each thread title I want to find is formatted as MM/DD/YYYY - description of an event.
These threads have a thread prefix tag of chapter_event or other.
The threads are sorted by title and an extra <br /> is placed between titles each time the month changes.
The problem is that I want to find thread titles that begin with today and the future.
I thought if I formatted a variable $today that I could compare it to the first 10 characters of the title string. This does not work. I can find the first 2 characters to omit previous months. I could also omit last year. But when I look for posts that are after today's day, previous posts are omitted.
PHP Code:
ob_start();
$output_bits = '';
$today = date("m/d/Y");
$spacer = date("m");
$get_schedule = vB::$db->query_read("
SELECT *
FROM ".TABLE_PREFIX."thread
WHERE prefixid='Chapter_Event' OR prefixid ='other' AND LEFT(title, 10) >= $today
ORDER BY title ASC");
while($schedule = vB::$db->fetch_array($get_schedule))
{
$str = substr($schedule[title], 0, 2); /* get month of event */
/* separates posts by month */
if ( $str == $spacer )
{
$output_bits .='<a target="_blank" href="showthread.php?t='.$schedule[threadid].'">'.$schedule[title].'</a><br />';
}
else
{
$output_bits .='<br /><a target="_blank" href="showthread.php?t='.$schedule[threadid].'">'.$schedule[title].'</a><br />';
}
$spacer = $str;
}
/* done */
$output = $output_bits;
ob_end_clean();
Comment