Location: PHPKode > scripts > Upcoming Events > kbupcomingevents/upcomingevents.php
<?PHP
include "config.php";
?>
<h1>Upcoming Events</h1>
<table border='0' cellspacing='0' cellpadding='0'>
<tr>
<td>
<?php

$wherequery="WHERE calitmact='1'";

$dtenow_ist= gmdate("Y-m-d" , time() +19800);
$yearnow_ist= gmdate("Y" , time() +19800);
$monthnow_ist= gmdate("m" , time() +19800);
$daydtenow_ist= gmdate("d" , time() +19800);
$mondaydtenow_ist= gmdate("m-d" , time() +19800);

$daydte25days_ist= gmdate("d" , strtotime ($dtenow_ist . '+25 days'));

if($daydtenow_ist>'7')
{
$monnext_ist= gmdate("m" , strtotime ($dtenow_ist . '+1 months'));
$yearnext_ist= gmdate("m" , strtotime ($dtenow_ist . '+1 years'));

$wherequery2="
(
calitmtypid='0' AND 
((MONTH(calitmdte)='$monthnow_ist' AND DAY(calitmdte) >='$daydtenow_ist')
OR
(MONTH(calitmdte)='$monnext_ist' AND DAY(calitmdte) <='$daydte25days_ist'))
)
";


$wherequery3="
(
calitmtypid='1' AND 
((YEAR(calitmdte)='$yearnow_ist' AND MONTH(calitmdte)='$monthnow_ist' AND DAY(calitmdte) >='$daydtenow_ist')
OR
(YEAR(calitmdte)='$yearnow_ist' AND MONTH(calitmdte)='$monnext_ist' AND DAY(calitmdte) <='$daydte25days_ist')
OR
(YEAR(calitmdte)='$yearnext_ist' AND MONTH(calitmdte)='$monnext_ist' AND DAY(calitmdte) <='$daydte25days_ist'))
)
";
}
else
{
$wherequery2="
(
calitmtypid='0' AND 
MONTH(calitmdte)='$monthnow_ist' AND DAY(calitmdte) >='$daydtenow_ist' AND DAY(calitmdte) <='$daydte25days_ist'
)
";

$wherequery3="
(
calitmtypid='1' AND 
YEAR(calitmdte)='$yearnow_ist' AND MONTH(calitmdte)='$monthnow_ist' AND DAY(calitmdte) >='$daydtenow_ist' AND DAY(calitmdte) <='$daydte25days_ist'
)
";
}


$wherequery="$wherequery AND ($wherequery2 OR $wherequery3)";

//echo "$wherequery";

$orderby="ORDER BY MONTH(calitmdte), DAY(calitmdte)";

 	$qry_calitems="SELECT * FROM scrupcomingevents $wherequery $orderby"; 
	$rsl_calitems=mysql_query($qry_calitems); 	
	$n_calitems = mysql_num_rows($rsl_calitems); 
	//$arr_calitems =  mysql_fetch_row($rsl_calitems);


if($n_calitems=='0')
{
echo "No Upcoming Events found in coming days<br>";
}
else
{
//echo "<b>$n_calitems Upcoming Events</b><br>";

echo "<ul>";
for($i=0; $i<$n_calitems; $i++)
{
$arr_calitems =  mysql_fetch_row($rsl_calitems);

$calitmdte_format=date('M jS',strtotime($arr_calitems[6]));;
$calitmdte_format2=date('m-d',strtotime($arr_calitems[6]));

if($calitmdte_format2==$mondaydtenow_ist)
{
$eventtdy_fontsize="font-size:14px; background-color: #CECEF6;";
}
else
{
$eventtdy_fontsize="";
}

//echo "$calitmdte_format2 $mondaydtenow_ist";

if($arr_calitems[7]=='0')
{

if($arr_calitems[10]!='')
{
$searchterm=$arr_calitems[10];
}
else
{
$searchterm=$arr_calitems[3];
}

$event_echo="<li style='$eventtdy_fontsize'>$calitmdte_format - <a href='index.php?page=d/search/basic&searchsub=1&searchterm=$searchterm' title='View our Collection on $arr_calitems[3]'><b>$arr_calitems[3]</b></a><br>
$arr_calitems[5]</li>";
}
else
{
$event_echo="<li style='$eventtdy_fontsize'>$calitmdte_format - <a href='index.php?page=d/ctg/item&itmctgid=$arr_calitems[7]' title='View our Collection on $arr_calitems[3]'><b>$arr_calitems[3]</b></a><br>
$arr_calitems[5]</li>";

}
echo "$event_echo";
}
echo "</ul>";
}

?>
</td>
</tr>
</table>

<b>* Please check these dates and events with the official Calendar.</b>
Return current item: Upcoming Events