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 Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/ 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? Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263009 Share on other sites More sharing options...
Zer0Cam Posted May 28, 2007 Author Share Posted May 28, 2007 Yes it sure is Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263015 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> Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263016 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... Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263020 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> Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263027 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 Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263033 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. Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263036 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. Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263039 Share on other sites More sharing options...
Zer0Cam Posted May 28, 2007 Author Share Posted May 28, 2007 I am still confused, lol Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263040 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 Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263055 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 Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263070 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. Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263074 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 Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263075 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. Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263076 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. Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263077 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 Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263078 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. Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263080 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?? Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263082 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. Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263083 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.. ??? Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263085 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. Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263086 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 Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263090 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. Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263092 Share on other sites More sharing options...
eZe616 Posted May 28, 2007 Share Posted May 28, 2007 later Link to comment https://forums.phpfreaks.com/topic/53230-quote-of-the-day-in-banner/#findComment-263095 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.