Jump to content

Quote of the day in banner


Zer0Cam

Recommended Posts

Ok then here is the code for the saying:

 

$quotes = array("Saying1", "Saying2", "Saying3", "Saying4");
$rand = rand(0,3);
$say = $quotes[$rand];

 

Then you should do something like this I guess for the image:

 

<tr>
<td style="background:url(http://www.yoursite.com/banner1.jpg)"><?php echo "$say"; ?></td>
</tr>

Hmmmmmmmm ok. Well here is what a sample page would look like:

 

<?php

$quotes = array("Saying1", "Saying2", "Saying3", "Saying4");
$rand = rand(0,3);
$say = $quotes[$rand];

?>

<table border=1>
<tr>
<td style="background:url(http://www.yoursite.com/banner1.jpg)"><?php echo "$say"; ?></td>
</tr>
<tr>
<td>Hey all, this is some text from my website!</td>
</tr>
</table>

Lets say I wanted to put this on the top of my SMF forum? ^^ up there would I put this in the index.template.php

 

Look where the banner is placed. if it's between a <td></td> then do what he did ^^ . be sure to add a width and height with the banner atrributes so the banner displays fully though.

Look inside your index.template.php where the Banner is placed.

 

lets say:

 

<table width="780" height="6oo">
<tr>
<td><img src="bannerurl.jpg"></td>
</tr>
</table>

 

instead of the

 

<td><img src="bannerurl.jpg"></td>

 

you replace it with

<td style="background:url(http://www.yoursite.com/banner1.jpg);width: 780px;height: ??px;"><?php echo "$say"; ?></td>

 

and for height and width, put the values of the width and height of the banner

Fair enough. Make a file called liked quotes.txt and put every quote on an INDIVIDUAL LINE! Thats very important. The code I am going to give you will read 1 line at a time from the file. Replace the stuff at the top with this:

 

$quotes = array();
$file = "quotes.txt";
$fh = fopen($file, 'r');
$i = 0;
while(! feof($file)) {
  array_push($quotes, gets($file));
  $i++;
}

fclose($fh);

$rand = rand(0,$i);
$say = $quotes[$rand];

 

No promises, but that should work.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.