Jump to content

I have a events script that works, it shows current and past events.


vet911

Recommended Posts

I have a events script that works, but it shows current and past events only. I want to be able to show all events by year or past or current events. I need some assistance to modify this script. Any help would be appreciated.

 

<?php
/* YOU SHOULD NOT HAVE TO EDIT ANY OF THIS PAGE */



require('config.php');

//determine if it a past or present display
if (isset($_GET['view']) && ($_GET['view'] == 'past')) {
$time = '>';
$opp_time = '<';
$no_events = 'past';
$back_events = 'upcoming';
$view = 'view=past';
$days_shown = 0;
$past = '';
$time = $opp_time;
}

else {
$time = '<';
$opp_time = '>';
$no_events = 'upcoming';
$back_events = 'past';
$view = '';
$days_shown = get_option('days_shown');
if ($days_shown == 0)
	$time = '>';
$past =  "&& (TO_DAYS(current) - TO_DAYS(DATE_ADD(NOW(), INTERVAL " . get_option('time_offset') . " HOUR)) " . $opp_time . "= 0) ";
}

//find the separator for the URL
if ($_GET['view'] == 'past')
$separator = '&';
else
$seprator = '?';

//check that table exists
$table_check = mysql_query("select * from " . $prefix . "events limit 0,1");
if ($table_check == true) {
?>


<table border="0" cellspacing="0" width="500">
<tr>
<td colspan="4">Sort by: <a href="?sort=current<?php echo $separator . $view; ?>">Date</a> / <a href="?sort=event<?php echo $separator . $view; ?>">Event</a> / <a href="?sort=location<?php echo $separator . $view; ?>">Location</a></td>
</tr>

<?php
/* List the upcoming events */

if (isset($_GET['sort']))
{
	$sort = $_GET['sort'];
	$query = mysql_query("SELECT * FROM " . $prefix . "events WHERE (TO_DAYS(current) - TO_DAYS(DATE_ADD(NOW(), INTERVAL " . get_option('time_offset') . " HOUR)) " . $time . "= " . $days_shown . ") && (status = 'show') " . $past . "ORDER BY " . $sort . " ASC");
}
else
	$query = mysql_query("SELECT * FROM " . $prefix . "events WHERE (to_DAYS(current) - TO_DAYS(DATE_ADD(NOW(), INTERVAL " . get_option('time_offset') . " HOUR)) " . $time . "= " . $days_shown . ")  && (status = 'show') " . $past . "ORDER BY current ASC");

$num = mysql_num_rows($query);
$inc = 1;
if ($num == 0)
	echo "<tr>\n\t<td><i>There are no " . $no_events . " events.</i></td>\n</tr>";
else {

while ($print = mysql_fetch_array($query)) {
	if ($inc% 2 == 0)
		echo '<tr>' . "\n";
	else
		echo '<tr bgcolor="#f0f0f0">' . "\n";

	//display proper event date
	$date = date("M d, Y", strtotime($print["current"]));
	$time = date("g:i A", strtotime($print["current"]));
	$enddate = date("D M d, Y", strtotime($print["end"]));
	$endtime = date("g:i A", strtotime($print["end"]));


if ($print["current"] != '0000-00-00 00:00:00'){
	echo "\t<td width='25%'>$date";
	if (!preg_match('/00\:00\:00/', $print["current"]))
		echo " <br />$time</td>"; }
else
	echo "\t<td> </td>";

	echo "\n\t<td><strong>" . $print['event'] . "</strong></td>";
	echo "\n\t<td>" . $print['location'] . "</td></tr>";

if ($inc% 2 == 0)
		echo "\n" . '<tr class="rows">';
	else
		echo "\n" . '<tr bgcolor="#f0f0f0">';
	echo "\n\t<td> </td>";
	echo "\n\t<td colspan='3'>" . $print['description'] . "</td>\n</tr>";
$inc++;
}
}
echo "\n";
?>
</table>

<p><a href="?view=<?php echo $back_events; ?>">View <?php echo $back_events; ?> events</a></p>

<?php }
else
echo '<p style="border: 1px solid #ff8e00; background: #ffe1a9; padding: .4em;">The event organizer has not yet been set up.</p>';

//get single option value
function get_option($name) {
global $prefix;
$find_option = @mysql_query("select option_value from " . $prefix . "options where option_name = '" . $name . "'");
$get_result = @mysql_fetch_object($find_option);

return $get_result->option_value;
}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.