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>

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

I was refering to my friend LOL, its an inside joke but Ok I got it to work but maybe you can help me with one more thing how would  I call it from a file? So I can put alot of quotes in instead of flooding my index.template file with quotes

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.