Zer0Cam Posted May 28, 2007 Share Posted May 28, 2007 Hey, I was wondering on how would I code a Quote of the day in the banner? Everytime someone refreshes it displays a quote of the day Quote Link to comment Share on other sites More sharing options...
StormTheGates Posted May 28, 2007 Share Posted May 28, 2007 Sure easily. Is it going to be placed over an image or just the text? Quote Link to comment Share on other sites More sharing options...
Zer0Cam Posted May 28, 2007 Author Share Posted May 28, 2007 Yes it sure is Quote Link to comment Share on other sites More sharing options...
StormTheGates Posted May 28, 2007 Share Posted May 28, 2007 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> Quote Link to comment Share on other sites More sharing options...
Zer0Cam Posted May 28, 2007 Author Share Posted May 28, 2007 And just how would I do this you gotta help me when it comes to these things were do I put this code etc... Quote Link to comment Share on other sites More sharing options...
StormTheGates Posted May 28, 2007 Share Posted May 28, 2007 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> Quote Link to comment Share on other sites More sharing options...
Zer0Cam Posted May 28, 2007 Author Share Posted May 28, 2007 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 Quote Link to comment Share on other sites More sharing options...
StormTheGates Posted May 28, 2007 Share Posted May 28, 2007 I dont know the SMF forum structure. Just find whatever file has the code for the banner in it and then put that at the top. Quote Link to comment Share on other sites More sharing options...
eZe616 Posted May 28, 2007 Share Posted May 28, 2007 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. Quote Link to comment Share on other sites More sharing options...
Zer0Cam Posted May 28, 2007 Author Share Posted May 28, 2007 I am still confused, lol Quote Link to comment Share on other sites More sharing options...
eZe616 Posted May 28, 2007 Share Posted May 28, 2007 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 Quote Link to comment Share on other sites More sharing options...
Zer0Cam Posted May 28, 2007 Author Share Posted May 28, 2007 I got it thanks, Some geek helped me with it I appreciate your help Quote Link to comment Share on other sites More sharing options...
StormTheGates Posted May 28, 2007 Share Posted May 28, 2007 Press the solved button then so we can all feel shiny  We are also nerds, not geeks by the way. Quote Link to comment Share on other sites More sharing options...
Zer0Cam Posted May 28, 2007 Author Share Posted May 28, 2007 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 Quote Link to comment Share on other sites More sharing options...
StormTheGates Posted May 28, 2007 Share Posted May 28, 2007 Reading from the file could be harder than putting it in a database and grabbing a random one from the db. Do you really want me to type out how to call from a file? Ill do it if you want to go that route, just saying calling from the db might be easier. Quote Link to comment Share on other sites More sharing options...
eZe616 Posted May 28, 2007 Share Posted May 28, 2007 LoL...yeah, I would do the DB also, only because I don't know how to do it with a file. . Also the db is easier to do also. Quote Link to comment Share on other sites More sharing options...
Zer0Cam Posted May 28, 2007 Author Share Posted May 28, 2007 Well a file would be more easy for me , So I can just upload it everytime I update it as I dont have database access at the moment Quote Link to comment Share on other sites More sharing options...
StormTheGates Posted May 28, 2007 Share Posted May 28, 2007 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. Quote Link to comment Share on other sites More sharing options...
eZe616 Posted May 28, 2007 Share Posted May 28, 2007 StormTheGates.I'm just asking out of curiosity. Is it possible to wrap the quotes into a tag and get them individually instead of a quote on every line?, like a xml file works with the child nodes?? Quote Link to comment Share on other sites More sharing options...
StormTheGates Posted May 28, 2007 Share Posted May 28, 2007 I dont believe there is a native PHP function for that. However I do think it would be possible with some nasty code. Quote Link to comment Share on other sites More sharing options...
eZe616 Posted May 28, 2007 Share Posted May 28, 2007 How about just using a xml file with nodes, and extract those with php??or i'm a asking the same question twice.. ??? Quote Link to comment Share on other sites More sharing options...
StormTheGates Posted May 28, 2007 Share Posted May 28, 2007 I am not sure to be honest. I never use files for anything if I am honest with you. I just use my database and its faster and safer. Quote Link to comment Share on other sites More sharing options...
eZe616 Posted May 28, 2007 Share Posted May 28, 2007 Allright...Just a question I thought might be interesting...DB for me 2..lol Quote Link to comment Share on other sites More sharing options...
StormTheGates Posted May 28, 2007 Share Posted May 28, 2007 And its now 2:15 am for me. So its drinking time for me. Night all. Quote Link to comment Share on other sites More sharing options...
eZe616 Posted May 28, 2007 Share Posted May 28, 2007 later Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.