Jump to content

Function Show Banner


balkan7

Recommended Posts

soryy my previous topic are solved and i start new topic whit good example to create 2 function for show banners, here is detail inforamtion for that...

 

banner_plans - i got 5 : 1. header, 2. sub-header, 3.right, 4.right2 and 5. footer.

banner_type - 0 is image, 1 is flash.

banner_state - 0 is inactive, 1 is active

 

plans 1,2,5 have same width and height, i wanna create one function for this.

plan 3 have difrent width and height, maybe need new function for this

and plan 4 have difrent W and H. same like plan 3.

 

code for Prepare Banners for display, functions are:

 

<?php function ss($text){
return stripslashes($text);
}

function setBannerView($banData){
global $db_prefix;
$currentData = explode(".", $banData['banner_clicks']);
$newViews = $currentData[1] + 1;
$lastData = implode(".", array($currentData[0], $newViews)); 
$updateViews = dbquery("UPDATE ".$db_prefix."btr_banners SET banner_clicks = '$lastData' WHERE banner_id = ".$banData['banner_id']."");
}

//Show Banner function
function showBanner($banData, $type="int"){
global $db_prefix;
setBannerView($banData);

if ($banData['banner_type'] == "0" AND $banData['banner_plans'] == "1"){
	$type = (strpos($banData['banner_img'], "http://") !== false) ? "ext" : "int";
	return "<a href='".INFUSIONS."marketing_panel/banner_click.php?banner_id=".ss($banData['banner_id'])."' target='_blank' title='".ss($banData['banner_name'])."'>
		<img alt='".ss($banData['banner_name'])."' src='".($type=="int" ? ss($banData['banner_img']) : ss($banData['banner_img']))."' border='0' width='468' height='60' />
		</a>";
} else {
	if ($banData['banner_type'] == "1" AND $banData['banner_plans'] == "1"){
		return "<embed width='468' height='60' src='".ss($banData['banner_url'])."' />";
 } 
}
}
//Prepare Banners for display
function displayBanners(){
global $db_prefix, $locale;
$bannersDb = dbquery("SELECT * FROM ".$db_prefix."btr_banners WHERE banner_state = '1'");
if (dbrows($bannersDb)){
	while ($tbData = dbarray($bannersDb)) $possRand[] = $tbData['banner_id'];
	$prCount = count($possRand)-1;
	$rand = mt_rand(0, $prCount);
	$banData = dbarray(dbquery("SELECT * FROM ".$db_prefix."btr_banners WHERE banner_state = '1' AND banner_id = ".$possRand[$rand]));
	return showBanner($banData);
} else {
	return $locale['BB_001']; 
}
}

 

Link to comment
Share on other sites

i have tried whit function but whiout result :(

 

<?php //Show Banner function
function showBanner($banData, $type="int"){
global $db_prefix;
setBannerView($banData);
if ($banData['banner_plans'] == "1"){
if ($banData['banner_type'] == "0"){
	$type = (strpos($banData['banner_img'], "http://") !== false) ? "ext" : "int";
	return "<a href='".INFUSIONS."marketing_panel/banner_click.php?banner_id=".ss($banData['banner_id'])."' target='_blank' title='".ss($banData['banner_name'])."'>
		<img alt='".ss($banData['banner_name'])."' src='".($type=="int" ? ss($banData['banner_img']) : ss($banData['banner_img']))."' border='0' width='468' height='60' />
		</a>";
} else {
	if ($banData['banner_type'] == "1"){
		return "<embed width='468' height='60' src='".ss($banData['banner_url'])."' />";
 } 
}
}
}?>

Link to comment
Share on other sites

i need difrent call plans because this not working propertly:

<?php if ($banData['banner_type'] == "0" AND $banData['banner_plans'] == "1") ?>

'banner_type' can't be == 0 AND == 1 in same time

if statement is allways false

Link to comment
Share on other sites

yes i my mistake start whit 0 but show banners whit 0 and 1

0 = jpg, gif

1 = swf

 

i have tried whit that but whitout result, ever show banner ever not show :(

<?php if ($banData['banner_type'] == "0" AND $banData['banner_plans'] == "1") ?>

 

soryy for bad english...

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.