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?
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.
Thank's!
I just get a block showing "Array"
Sorry. My fault. I changed my mind halfway through writing the code. Try the new code.
Thank's! :)
One more question:
Now when this works, where can I find a fairly big TP banner to have there?
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
i got an error.
i set it as a scriptbox.
see image below.
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fwww.picattic.com%2Ffiles%2Fjvm9sdba9r9q3bskiz29_thumb.jpg&hash=c82db94acd43c0b2eb2ca2cacef481f5f79c2d47) (http://www.picattic.com/viewer.php?file=jvm9sdba9r9q3bskiz29.jpg)
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?
It should be a PHP block.
that seems to have done it.
thank you. :)
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?
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.
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. :)