PDA

View Full Version : PHP Code help


betts02
09-03-2010, 01:09 PM
I have released a mod for a simple forum block upcoming events

It pulls the data from the calendar but when it is sowing, It is showing for the day before

Can anyone help on this ? So i can update the mod for others to use ?

The code i have is:

ob_start();


// %d
$show_count = 5;

$query = sprintf("SELECT * FROM ".TABLE_PREFIX."event WHERE visible = 1 AND (dateline_from > '%d' || ( dateline_from > '%d' AND dateline_to < '%d' )) ORDER BY dateline_from ASC LIMIT %d",TIMENOW,TIMENOW,TIMENOW,$show_count);

$event_get = vB::$db->query_read($query);

$output_bits = '';
while($event = vB::$db->fetch_array($event_get)) {

if($event['dateline_to'] == 0 )
{
$format = sprintf("On %s",date('jS M Y',$event['dateline_from']));
} else {
$format = sprintf("From %s to %s",date('jS M Y',$event['dateline_from']),date('jS M Y',$event['dateline_to']));
}

$output_bits .= sprintf('
<div class = "cms_widget_post_bit"><h4 class="cms_widget_post_header"><a href="calendar.php?do=getinfo&e=%d">%s</a></h4>
<p class="cms_widget_post_content">%s</p>
</div>
',$event['eventid'],$event['title'],$format);

}
$output = $output_bits;


ob_end_clean();
return $output;

Cheers in advance

Lynne
09-03-2010, 02:09 PM
Where are you getting the date/time? And are you adjusting the date to the users timezone?

betts02
09-03-2010, 02:28 PM
All i know is it takes it from the calendar, In the mod i put up i stated this and that i am no coder and do not support it, but if i could get it working to the exact date then others can use it better

Lynne
09-03-2010, 05:15 PM
I just put this mod on my forum. It says Upcoming Events and then it shows me something coming up tomorrow. That seems to be acting correct (tomorrow is upcoming). What is it you want it to do?

betts02
09-03-2010, 06:18 PM
In my calendar, I posted an event for the 5th, In my forum block, It has the event, But the date says the 4th

Lynne
09-03-2010, 07:12 PM
Ah, now I see what you mean (I titled mine by the date, so it looked correct to me). All the stuff to get the dates is in the forum.php file. I've never really played with the calendar dates to see how they get manipulated, so all I can really do is point you to forum.php which is where they prepare it for the Events area on the forum page.