balkan7 Posted February 28, 2008 Share Posted February 28, 2008 hi guys i have code for show banner, so i have many places for banner show but i wanna create one function array for show banner whit more place like 1-Header,2-Sub-Header,3-Right,4-Left,5-Footer. table - banners_plans plan_id int(10) NOT NULL auto_increment, plan_name varchar(100) NOT NULL default '', plan_place varchar(100) NOT NULL default '', plan_width int(11) NOT NULL, plan_height int(11) NOT NULL, table - banners banner_plan_id tinyint(1) NOT NULL default '', this is second row. function code for show banners: <?php if (!defined("IN_FUSION")) { header("Location:../index.php"); exit; } 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."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'] == "1" or $banData['banner_type'] == "2"){ $type = (strpos($banData['banner_img'], "http://") !== false) ? "ext" : "int"; return "<a href='".INFUSIONS."marketing_panel/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'] == "3"){ 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."banners WHERE banner_status = '1'"); if (dbrows($bannersDb)){ while ($tbData = dbarray($bannersDb)) $possRand[] = $tbData['banner_id']; $prCount = count($possRand)-1; $rand = mt_rand(0, $prCount); //check ownership user to client id // if($banData['client_id'] != $userdata['user_id']) // { //add the impression // dbquery("update ".$db_prefix."btr_banners set banner_impmade = banner_impmade+1 where banner_id = ".$banData['banner_id'].""); // } // $banData = dbarray(dbquery("SELECT * FROM ".$db_prefix."banners WHERE banner_status = '1' AND banner_id = ".$possRand[$rand])); return showBanner($banData); } else { return $locale['BB_001']; } } ?> for show i used function displayBanners(); can it possible to call displayBanners() function to array like displayBanners(2) for every place difrent array? i hope can undenstand me! Link to comment https://forums.phpfreaks.com/topic/93511-function-array-show/ Share on other sites More sharing options...
balkan7 Posted February 28, 2008 Author Share Posted February 28, 2008 plz someone help i need it ... Link to comment https://forums.phpfreaks.com/topic/93511-function-array-show/#findComment-479501 Share on other sites More sharing options...
p2grace Posted February 28, 2008 Share Posted February 28, 2008 Could you re-word the question. I'm a little confused by exactly what you're asking. Thank you. Link to comment https://forums.phpfreaks.com/topic/93511-function-array-show/#findComment-479557 Share on other sites More sharing options...
balkan7 Posted February 28, 2008 Author Share Posted February 28, 2008 hi, i need create array in displayBanners(); for places (table - banners_plans) i got many places and when i call banner for header i wanna call like array ->displayBanners(1); for sub-header ->displayBanners(2); but i need someone help me whit that code. i hope you can undestand me now ! Thanks Link to comment https://forums.phpfreaks.com/topic/93511-function-array-show/#findComment-479583 Share on other sites More sharing options...
balkan7 Posted February 29, 2008 Author Share Posted February 29, 2008 bump ??? Link to comment https://forums.phpfreaks.com/topic/93511-function-array-show/#findComment-480134 Share on other sites More sharing options...
nadeemshafi9 Posted February 29, 2008 Share Posted February 29, 2008 this guys pretending to be foreghn and he realy just needs some code Link to comment https://forums.phpfreaks.com/topic/93511-function-array-show/#findComment-480167 Share on other sites More sharing options...
balkan7 Posted February 29, 2008 Author Share Posted February 29, 2008 i have explame whit first post. ok i'm not sure we need create code inside function displayBanners(); and display banners whit array like displayBanners(2); test code: //Prepare Banners for display function displayBanners($plans=1){ global $db_prefix, $locale; $result = dbquery("SELECT * FROM ".$db_prefix."banners_plans"); $numrows = dbrows($result); if ($numrows != ""){ while ($data = dbarray($result)) { $plan_id = $data['banner_plan_id']; $plan_array = array($plan_id); $plan_dot = explode(".",$plan_array); $plans = $plan_dot; } $bannersDb = dbquery("SELECT * FROM ".$db_prefix."banners WHERE banner_status = '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."banners WHERE banner_status = '1' AND banner_id = ".$possRand[$rand])); return showBanner($banData); } else { return $locale['BB_001']; } } } maybe my code is wrong can someone help ? Link to comment https://forums.phpfreaks.com/topic/93511-function-array-show/#findComment-480214 Share on other sites More sharing options...
balkan7 Posted February 29, 2008 Author Share Posted February 29, 2008 i think i find solution, but i need more secure inside. plz help if you have better solution. code: <?php //Prepare Banners for display function displayBanners($place=1){ global $db_prefix, $locale; $result = dbquery("SELECT * FROM ".$db_prefix."banners_plans"); $numrows = dbrows($result); if ($numrows != ""){ while ($data = dbarray($result)) { $plan_id = $data['plan_id']; $plan_array = array($plan_id); $plan_imp = implode(",",$plan_array); $plans = $plan_imp; //if (in_array($place, $plans)) } $bannersDb = dbquery("SELECT * FROM ".$db_prefix."banners WHERE banner_status = '1' and banner_plan_id = ".$place); 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."banners WHERE banner_status = '1' AND banner_id = ".$possRand[$rand])); return showBanner($banData); } else { return $locale['BB_001']; } } }?> Link to comment https://forums.phpfreaks.com/topic/93511-function-array-show/#findComment-480290 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.