TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

May 18, 2024, 11:43:43 PM

Login with username, password and session length
Members
  • Total Members: 3,886
  • Latest: Grendor
Stats
  • Total Posts: 195,189
  • Total Topics: 21,220
  • Online today: 112
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 1
  • Guests: 94
  • Total: 95
  • @rjen

[Request] Bottom block - Random advertise + banner

Started by MTF95, May 31, 2008, 06:38:54 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MTF95

Hi!

Can anyone create a PHP code which shows a random banner + a short text for each of them that I can use in a bottom panel?

JPDeni

#1
Random stuff is really simple. First, come up with the html for each thing you want. Something like:


<img src="http://url.to.somedomain/images/image.jpg"><br />Text to go below that image


Then stick them all into an array, randomize the array, and display the top one.


$stuff= array (
        '<img src="http://url.to.somedomain/images/image.jpg"><br />Text to go below that image',
        '<img src="http://url.to.someotherdomain/images/otherimage.jpg"><br />Text to go below that other image',
  );

shuffle($stuff);

echo $stuff[0];


It'll randomize however many you put in, so if you want one to show up more often than others, you'll need to put it in multiple times.


MTF95


JPDeni

#4
Sorry. My fault. I changed my mind halfway through writing the code. Try the new code.


MTF95

One more question:
Now when this works, where can I find a fairly big TP banner to have there?

IchBin

Pretty much anything you have a questions about has already been posted. Even random rotating banners has been posted 10 times at least. Feel free to use the search button here for your questions. You'll even find some banners that were posted quite some time ago.

http://www.tinyportal.net/index.php?topic=5091.0

Reality12

i got an error.

i set it as a scriptbox.

see image below.



it's on the left, under "MARKETS."

this is what i am doing:

$stuff= array (
        '<a target="new" href="http://www.url.com/directory/image.jpg"><img src="http://www.url.com/directory/image.jpg" width"180" height="170"></a>',
        '<a target="new" href="http://www.url.com/directory/image1.jpg"><img src="http://www.url.com/directory/image1.jpg" width"180" height="170"></a>',
  );

shuffle($stuff);

echo $stuff[0];


where did i go wrong?


Reality12


Reality12

#11
two more things...

i'd like the images centered.

adding an html 'center' code, doesn't work.

can someone advise?

second. the width of the images don't seem to change, no matter what i do.

any clue?

JPDeni

Quoteadding an html 'center' code, doesn't work.

It should. You didn't tell us what you tried and what "doesn't work" means, but I'll tell you one way that I know works:


echo '<center>';
echo $stuff[0];
echo '</center>';


Quotesecond. the width of the images don't seem to change, no matter what i do.

What have you done? It should work just fine if you add height and width attributes to the img tag.

Reality12

i was using '<center>' and '</center>'.

one at the very top, and the other at the very end.

regarding the height and width, i just realized my mistake...

i was using:

width"152" height="170"

but as you can see, there was an oversight.

it should have been:

width="152" height="170"

thanks again JPDeni. :)