Location: PHPKode > projects > qEngine > module/qbanner/window.php
<?php
// get param
$type = strtoupper (mod_param ('banner_type'));

$row = sql_qquery ("SELECT MAX(idx) AS max FROM ".$db_prefix."banner LIMIT 1");
if (!empty ($row['max']))
{
	$rnd = mt_rand (1, $row['max']);

	if (empty ($type))
		$res = sql_query ("SELECT * FROM ".$db_prefix."banner WHERE idx > $rnd LIMIT 1");
	else
		$res = sql_query ("SELECT * FROM ".$db_prefix."banner WHERE idx > $rnd AND banner_type='$type' LIMIT 1");
	$row = sql_fetch_array ($res);

	if (empty ($row))
	{
		if (empty ($type))
			$res = sql_query ("SELECT * FROM ".$db_prefix."banner WHERE idx <= $rnd LIMIT 1");
		else
			$res = sql_query ("SELECT * FROM ".$db_prefix."banner WHERE idx <= $rnd AND banner_type='$type' LIMIT 1");
		$row = sql_fetch_array ($res);
	}

	if (!empty ($row))
	{
		$output  = "<div style=\"text-align:center\">";
		$output .= "<a href=\"$row[banner_url]\"><img src=\"public/image/$row[banner_file]\" alt=\"$row[banner_title]\" /></a>";
		$output .= "</div>";
	}
	else
		$output = "<!-- banner_type_$type is not defined! please add it in acp -->";
}
else
	$output = '<!-- no banner found -->';
?>
Return current item: qEngine