<?php
	// banner id
	$b_id = 1;
	// current time
	$plus_time_today = strtotime ("+0 hour");
	$current_date = date(Y."-".m."-".d, $plus_time_today); 
	// empty banner
	$banneri = '<img src="banner/empty.jpg" border="0">';
	// banner function
	if($b_id != "")
	{
		$b_query = "SELECT * FROM banners_info WHERE id = '$b_id'";
		$b_result = mysql_query($b_query, $db);
		if($b_myrow = mysql_fetch_array($b_result))
		{
			// empty banner
			$banneri = '<img src="banner/empty.jpg" width="'.$b_myrow['width'].'" height="'.$b_myrow['height'].'" border="'.$b_myrow['border'].'" style="'.$b_myrow['style'].'">';
			// check view
			if(($b_myrow['end_date'] > $current_date) && ($b_myrow['status'] == 1) && ($b_myrow['img'] != ""))
			{
				// url
				$start_url = '';
				$end_url = '';
				if($b_myrow['url'] != "")
				{
					$start_url = '<a href="'.$b_myrow['url'].'" target="_blank" title="'.$b_myrow['title'].'">';
					$end_url = '</a>';
				}
				// banner img
				$banneri = '<img src="'.$b_myrow['img'].'" width="'.$b_myrow['width'].'" height="'.$b_myrow['height'].'" border="'.$b_myrow['border'].'" style="'.$b_myrow['style'].'">';
				// write banner
				echo($start_url.$banneri.$end_url);
				// count view
				$b_view = $b_myrow['view'];
				$b_view = $b_view + 1;
				// view write to db
				mysql_query("UPDATE banners_info SET view = '$b_view' WHERE id = '$b_id'", $db);
			}
			else
			{
				// empty banner
				echo($banneri);
			}
		}
	}

?>
