Jump to content

Recommended Posts

Hello All...

 

I have a script that includes a 'showbanner.php' file on a page.  It's pretty straight forward.

 

When I duplicate the file, changing the type of banner and include that also, the page just mixes up all of the banner types, rather than keeping just the type I want in the place I want.

 

Here's the code:

 

$qsb = "select BannerID from banners where BannerType = 'Top' ";

$rsb = mysql_query($qsb) or die(mysql_error());

if(mysql_num_rows($rsb) > '0')
{
while($asb = mysql_fetch_array($rsb))
{
	$NewBannersArray[] = $asb[bannerID];
}

$DisplayBannerID = array_rand($NewBannersArray);

$BannerID = $NewBannersArray[$DisplayBannerID];

//get the selected banner info
$qsb2 = "select * from banners where BannerID = '$BannerID' ";
$rsb2 = mysql_query($qsb2) or die(mysql_error());
$asb2 = mysql_fetch_array($rsb2);

echo "<A href=\"re_counter.php?BannerID=$BannerID\"><img src=\"/directory/banner_images/$asb2[bannerFile]\" alt=\"$asb2[bannerAlt]\" border=0></a>";


$date_now = time();

$this_ip = $_SERVER[REMOTE_ADDR];

$qsb3 = "insert into banner_stats set 
				BannerID = '$BannerID',
				impressions = '1',
				mydate = '$date_now',
				ip = '$this_ip' ";

mysql_query($qsb3) or die(mysql_error());
}

 

I thought I could create another showbanner file. (showbannerbottom.php), let's say and just change the tupe at the top.

 

Didn't work.

 

Any suggestions?

Sorry I wasn't clear...

 

Yes, each file will run independently just fine.  It is exactly as you said, because the variables are named the same in each file, the banners just show up randomly, instead of with the correct 'type' in the correct place.

 

I wanted to know if anyone knew how to write it so either it's just one file (instead of include bannertop, include bannerbottom, etc. on the page) - or how to change the variable in each file.

 

Is it as simple as renaming qsb/rsb to asb/bsb/csb, etc?  - although that seems awfully messy.

 

As you can tell, I'm learning php!

 

:o

Great, that did it!  I went through each of my banner files and just added a unique letter for each file after the $.

 

It's probably messy programming, but it works.

 

Someday I'll brilliantly produce a sing, 2-line piece of code that will solve all of the world's web problems... until then, thanks for the feedback everyone!

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.