Using the "Random Quote" php SNIPPET...

User 1854541 Photo


Registered User
34 posts

I'm using HTML Editor 2010se, Build 369, and would like to use the "Random Quote" snippet within a blockquote div on our pages (PawPADs.org). Can anyone explain how to use this? This is my first and only website! Thanks CC for a REALLY GREAT product!
Please help me understand this and life in general:


Add line of code to page where you want quotes to appear

****** <?php include "random_quote.php"; ?> ********


<?php

$quotes [ ] = " This is a quote";

$quotes [ ] = " This is a quote 2";

$quotes [ ] = " quote 3";

$quotes [ ] = " quote 4";

$quotes [ ] = " quote 5";

$quotes [ ] = " quote 6";

$quotes [ ] = " quote 7";

$quotes [ ] = " quote 8";

srand ((double) microtime () * 1000000);

$randomquote = rand (0, count ($quotes)-1);

echo "<p>" . $quotes [$randomquote] . "</p>';

?>
Randy Patrick
"I am only one, but I am one. I cannot do everything, but I can do something. I will not let what I cannot do interfere with what I can do. " ~ Edward Everett Hale
User 38401 Photo


Senior Advisor
10,951 posts

Hiya Randy,

That snippet would be something you use as a PHP Include setup. I don't think you "have" to do it that way, but that's what it is setup for in that situation. To do exactly what it's asking you for you would take the selection of code below and put that into a separate file without any html tages at all, just this code and nothing else. Save the file as random_quote.php making note of the .php extension which is needed instead of .txt or .html


<?php

$quotes [ ] = " This is a quote";

$quotes [ ] = " This is a quote 2";

$quotes [ ] = " quote 3";

$quotes [ ] = " quote 4";

$quotes [ ] = " quote 5";

$quotes [ ] = " quote 6";

$quotes [ ] = " quote 7";

$quotes [ ] = " quote 8";

srand ((double) microtime () * 1000000);

$randomquote = rand (0, count ($quotes)-1);

echo "<p>" . $quotes [$randomquote] . "</p>';

?>


Then in your page that you want the quotes to show up in you put this where you want the quotes to be and it will then read from that page you saved above:

<?php include "random_quote.php"; ?>


Put that inside a <div></div> set or however you're putting it into your page.

Be sure your page is then saved as .php pages instead of .html also if I recall.

Hope that works out for you and that answers your question :)


Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.