Here's a little random quote script that you can use to randomly choose from an array of quotes you provide. It's very easy to use on any page as it's an external script, you just call it from your page. I wouldn't use it for any more than about 50 quotes though, it would probably slow your site down too much. Here's the code:
CODE
var ar = new Array(44) ar[0] = "Do not meddle in the affairs of wizards, for they are subtle and quick to anger." ar[1] = "Faithless is he that says farewell when the road darkens." ar[2] = "I cordially dislike allegory in all its manifestations, and always have done since I grew old and wary enough to detect its presence. " ar[3] = "If more of us valued food and cheer and song above hoarded gold, it would be a merrier world." ar[4] = "It's a job that's never started that takes the longest to finish." ar[5] = "Little by little, one travels far." ar[6] = "I don't know half of you half as well as I should like; and I like less than half of you half as well as you deserve." ar[7] = "It's a dangerous business going out your front door." ar[8] = "All that is gold does not glitter." ar[9] = "His house was perfect, whether you liked food, or sleep, or work, or story-telling, or singing, or just sitting and thinking, best, or a pleasant mixture of them all." ar[10] = "Many that live deserve death. And some die that deserve life. Can you give it to them? Then be not too eager to deal out death in the name of justice, fearing for your own safety. Even the wise cannot see all ends." ar[11] = "'I wish life was not so short,' he thought. 'Languages take such a time, and so do all the things one wants to know about.'" ar[12] = "Still round the corner there may wait, a new road or a secret gate." ar[13] = "There I lay staring upward, while the stars wheeled over... Faint to my ears came the gathered rumour of all lands: the springing and the dying, the song and the weeping, and the slow everlasting groan of overburdened stone." ar[14] = "Courage is found in unlikely places." ar[15] = "Advice is a dangerous gift, even from the wise to the wise." ar[16] = "The world changes, and all that once was strong now proves unsure." ar[17] = "All we have to decide is what to do with the time that is given to us." ar[18] = "The world is indeed full of peril, and in it there are many dark places; but still there is much that is fair; and though in all lands love is now mingled with grief, it grows perhaps the greater." ar[19] = "But I expect they had lots of chances, like us, of turning back, only they didn't. And if they had, we shouldn't know, because they'd have been forgotten. We hear about those as just went on -- and not all to a good end, mind you; at least not to what folk inside a story and not outside it call a good end." ar[20] = "The board is set, the pieces are moving. We come to it at last... The great battle of our time." ar[21] = "The Darkness has begun. There will be no dawn." ar[22] = "Their plans were improved with the best advice." ar[23] = "With hope or without hope we will follow the trail of our enemies. And woe to them, if we prove the swifter!" ar[24] = "Their Oath shall drive them, and yet betray them, and ever snatch away the very treasures that they have sworn to pursue." ar[25] = "The treacherous are ever distrustful." ar[26] = "He should not vow to walk in the dark, who has not seen the nightfall." ar[27] = "Few can foresee whither their road will lead them, till they come to its end." ar[28] = "It's wisdom to recognize necessity, when all other courses have been weighed, though as folly it may appear to those who cling to false hope." ar[29] = "For though I do not ask for aid, we need it." ar[30] = "I have no help to send, therefore I must go myself." ar[31] = "What do you mean? Do you wish me a good morning, or mean that it is a good morning whether I want it or not; or that you feel good on this morning; or that it is a morning to be good on?" ar[32] = "He that breaks a thing to find out what it is has left the path of wisdom." ar[33] = "The deeds will not be less valiant because they are unpraised." ar[34] = "I sit beside the fire and think of all that I have seen." ar[35] = "I wish I had never come here, and I don't want to see no more magic." ar[36] = "The Road goes ever on and on, down from the door where it began." ar[37] = "It all comes from here, the stench and the peril." ar[38] = "But only a short way ahead its floor and the walls on either side were cloven by a great fissure, out of which the red glare came, now leaping up, now dying down into darkness; and all the while far below there was a rumour and a trouble as of great engines throbbing and labouring." ar[39] = "A box without hinges, key, or lid, yet golden treasure inside is hid." ar[40] = "Go not to the elves for counsel, for they will say both yes and no." ar[41] = "I am told that I talk in shorthand and then smudge it." ar[42] = "It does not do to leave a live dragon out of your calculations, if you live near him." ar[43] = "Not all who wander are lost." var now = new Date() var sec = now.getSeconds() document.write("<table cellspacing='0' cellpadding='0' border='0'>") document.write("<tr><td><img src='img/scroll_top.gif' width=160 height=37 border=0 alt=''></td></tr>") document.write("<tr><td background='img/scroll_mid.gif'><table align='center' cellspacing='5' cellpadding='5' border='0'><tr>") document.write("<td valign='top'><font size=-1><i>" + ar[sec % 44] +"</i></font><font size=-1 color=#800000><p align='right'><b>J.R.R. Tolkien</b></p></font></td></tr></table>") document.write("</td></tr><tr><td><img src='img/scroll_bot.gif' width=161 height=27 border=0 alt=''></td></tr></table>")
The variables you need to set are the top line "var ar = new Array(44)" 44 is the number of quotes, in this case we start at 0 and go to 43, that's 44 lines. Then of course you need set each of the quote variables "ar[0], ar[1], ar[2]" etc to your quotes.
The "document write" statements format the text and display it on the page. You will want to change the images used in the table to what ever images you want to use.
Copy and paste the code above into a text editor, make your changes and save the file as "quote.js" and then upload it to the server.
To call the script you just need to put this code in your page wherever you want the quotes to appear.
CODE
<script src="quote.js"></script>
This assumes the script is in the the same directory as the page calling the script.
An example of the above script can be seen here. Look in the bottom left corner of the page, reload the page to see a new quote.
Have fun with it!
Notice from cmatcmextra:
Use [-codebox-] tags when writing long lines of code! This is script - it does not discuss any website - moving out of Website Discussion --> General
I like truefusion's php solution better, it's a lot simpler. I'll use that in the future. All you'd need to do is save it as a php page by itself and then use an 'include' statement wherever you want it on the other page. Good work!
I guess the javascript is handy for when you don't have access to php, but that's not a problem at Trap17.
Background Image Changer Script To swap the background image from your CSS file according to the
Server Clock Time. 1.) In your CSS file, add the following rule: CODE body {
background: url(time.png); } 2.) Create a "folder" named time.png. 3.) Into the
folder, place three images named morning.png, day.png, night.png. 4.) Also, in the same folder,
create an index.php file and copy/paste the following script. CODE <?php $hour =
date('H'); if ($hour < 12 ) { $image =
"morning.png"; } ...
Hello all, A little bit back I decided to make a quiz scriptjust out of no where lol. However it
doesnt do anything special but I am going to make an email mod for it so that it will email results
to your email address. So here is the basis of it. INSTRUCTIONS: Open a new page in your text
editor and paste in the following code. CODE <?php $qid = "Quiz ID-00"; ?>
<html> <head> <title><? echo "Gamers Pub $qid";
?></title> </head> <body> <p><h3><? echo "...
PHP Random Titles Description Ever wondered how some websites (ex:spoono.com) have those cool-o
random titles appearing in the title bar? Now you get to learn how to do it using PHP. We will be
using our knowledge of Variables and Echos in this tutorial. Try It Out Creating the code itself
is fairly easy. To start, lets create some of our different titles. Code CODE <?php
$title[1] = "This will be more fun that that time - never mind...";
$title[2] = "Another random title... neat eh?"; $title[3] = ...
In case you haven't noticed, I have a different Avatar display on the Forum each time the page
is refreshed. /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif"
/> For those of you who might want the script to do that, here is the one I am using: HTML
$filesp = glob('*.png'); if(empty($filesp)){ echo
'no images found...die br >'; die(); } else{ foreach ($filesp as
$file) { $img_array[] = trim($file); }...
Be sure to read the other ones. They are located in the TUTORIALS section, and at the time of this
writing all on the first page. Intro To PHP Tutorial 5 - For ... Next Loops and Planning Scripts
Released 4/15/07 By Chris Feilbach aka GhostRider Contact Info: E-mail: assembler7@gmail.com AIM:
emptybinder78 Yahoo: drunkonmarshmellows Website: http://www.ghostrider.trap17.com Before I start
talking about what wonderful things loops are and all the cool stuff they can do, I want to address
something first. I was asked about something to write in PHP. There isn't...
PHP - Randomize Web Title with the rand function... Define the variables numbers we start at number
0 CODE <?php $title[0] = "Web title 0"; // Title 0
$title[1] = "Web title 1"; // Title 1 $title[2] = "Web title
2"; // Title 2 $title[3] = "Web title 3"; // Title 3
$title[4] = "Web title 4"; // Title 4 ?> now we use the rand()
function to get a randomize the web title. rand(0, 4) means we start at 0 and end at 4 i can get
0,1,2,3,4 one of those. ...
How To: IP Configuration Script (win XP) If you travel a lot with your laptop, and need to switch
between different IP's in different locations, this script is for you. There are many programs
that handle this task very well, but they cost sometimes pretty big money. This tutorial will show
you how to make your own IP Configuration Script for free. This script is for a static ip address
configuration and is based on a little program called "NETSH.EXE" which is supplied with Windows.
How it works. QUOTE Microsoft Windows XP - Using Netsh Netsh.exe is a...
Well, it has been a while since I have added anything to the Tutorial Sectiion, so here is another
script for the members to enjoy. This one creates a list of links from the contents of the directory
which it is run from. For instance, if you run it from the public_html folder, then all the files
(not the Directores) are listed and linked so when you click on the link, that file is parsed and
output to the browser. Here is the code: "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
An XHTML 1.0 Strict Page to List the files in this directory ...
Today, I'm going to show you how to make an email script using PHP and HTML. Most people usually
put Email me if they want an email link on their site, but there are several cons to this.
First, it's very inconvenient for those people who use web-based mail such as Yahoo!,
Hotmail, or Gmail because that darn Micro$oft Outlook program comes up if one accidently click
the link. Second, you are very suseptible to spam bots because they scan your HTML source code for
anything with the same pattern as an email address and add it to their database. If yo...
this is a script used to tell you or visitors how fast your page was generated for the person who is
viewing it... Ok it is verry simple!! all you have to do is put this script on every
page... that you want it to be on CODE <?php $starttime = explode(' ',
microtime()); $starttime = $starttime[1] + $starttime[0];
?> and put it before everything on the page, for me i put it right underneith the DOCTYPE
script which i think is a bloody waste of space to have it on there, but anyways.. ...
Just follow the instructions below: /* Secure Email Function by Juan Karlo Aquino de
Guzman Website: http://www.karlo.ph.tc and http://www.abs-cbn.ph.tc E-mail:
http://www.karlo.ph.tc/send.php Usage: showEmail("support@microsoft.com",0); OR
showEmail("support@microsoft.com",1); Types: 0 = ordinary random 1 = more secure random To
include to a script: include_once("email_secure.php"); */ And here is the code :
CODE <?php /* Secure Email Function by Juan Karlo Aquino de Guzman Website:
http://www.karlo....
A Php Menu-builder Tutorial This Sidebar Menu-builder code and the php scripts are adapted from
a Tutorial on the Astahost.com Forum titled : CMS101 - Content Management System Design .
Since the original tutorial's author (vujsa) did such a marvellous job of describing the system
in the original Topic posting, I will not attempt to explain it here, rather, I invite you to have a
look at his Topic and learn from it. The Basic tutorial provided coding for developing a table-based
web-site template which used php includes and embedded data to create a &...
Another Unordered List Script If you remember this Script , that tutorial was about creating
an un-ordered list of links from a list of files contained in a Folder which was specifically named
in the script. This current Tutorial goes several steps beyond that first Tutorial by being able to
create a list from several folder names and, more importantly, the script reads the list of links
from a 'flat file' rather than depending on the name of the folder to be hard coded in the
script. It is only one small step to have the folder names found in a mysql ...
This tutorial is using TRAP17 hosting's built-in script called cgiemail. There are several
hundreds of free scripts you can download and install it yourself but why not use what is already
provided for you, if all you need is a simple submit and data collection? Let's begin. There
are three things you need to remember: 1) you can rename the file however you'd like 2) two
files (which I'll name them submitForm.html and template.txt ) must be in the same directory
3) first two lines in template.txt must EXIST. Write your submitForm.html (where you ...
This simple script will allow you to run some basic checks to make sure that any email address
entered is actually an email address. There is no guarantee offered that this will stop every single
fake email address, but it'll provide some protection. Now, the code! First we need to get
the email address to verify. Here, I get it using POST from an HTML form. CODE <?php //Load
email address from web form $email = $_POST['email']; Now, we move on
to our first check. Does the text that has been entered look like it could b...
An example of this script cna be found at http://www.own.tc/ (click enter) This is by far the
BEST stats script and most sites use it! This is a PHP script and requires you to include files
(Please... don't do iframes!) DOWNLOAD LINK: GO TO www.ZYMIC.com and go to Php scripts>stats
scripts> and the current version of NDSTATS. Downlaod it and unzip it! Go to your WWW directory
and create a folder called "ndstats". Then what you need to do is upload all of your files into
that folder. You all should know how to do that. Then go to the top of the pag...
Are you pissed off when you are putting e-mail in your website, you always get spammers? Well,
here's the solution. Just change the default variables to anything that you like, etc... follow
the instructions on the script.. Here it is... hope you like it /smile.gif' border='0'
style='vertical-align:middle' alt='smile.gif' /> CODE <?php //E-mail Mailer Script 0.1
by Juan Karlo de Guzman //FOR TRAP17 ONLY... DEMO VERSION... DO NOT DISTRIBUTE
header("Content-type: text/html; CHARSET=UTF-8");
$int_rand=mt_rand(1,20); if...
This tutorial will give you the code needed and tell you how to implement it. First off you need to
create a file called mailing.php this will be the file that processes the adding of emails to the
list. CODE <?php $email = $_POST['email']; $file =
fopen("mailing.txt", "a"); fwrite($file, "\n" .
$email); fclose($file); header("Location:
mailing_thankyou.php"); ?> Next you need to create a file called
mailing_thankyou.php , simple a p...
save this page as formmail.php Code: QUOTE $MailTo = "your email"; $MailSubject
= "contact"; $MailHeader = "From: $s1"; $MailSent = "Put here the information you
want to be shown after the message is sent."; if ($s1 == ""){ echo "You did not put your
name ."; } else { $MailBody = "Name : $s1\n"; } if ($s2 == ""){ echo "You did
not put your E-Mail ."; } else { $MailBody .= "Email : $s2\n"; } if ($s3 ==
""){ } else { $MailBody .= "Message : $s3\n"; } { mail($MailTo...
Here's the guessing script, they guess a number and checks if they are right or wrong.. CODE
<form method="guess.php?action=yes"> <input type="text"
name="t_guess"> <br> <input type="submit" value="Guess">
<?php if($action==yes){ //have the number that they are suppose to guess...
$guess=14; //end if($t_guess==$guess){ print "Good job! Guess was
right!"; }else{ print "Guess was wrong! Try again!"; } } ?> Tha...
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE
forum, Create your own topics, Ask Questions, track topics, setup
subscriptions & notifications and Get a Free Website w/ Email and FTP.