/    Sign up×
Community /Pin to ProfileBookmark

All right, first off, here’s my website: [url]http://www.zeldalegends.net/[/url]

What I want to do it put a random quote on top of the column to the right, which is part of a table. Similar to what they have at this site: [url]http://www.wotmania.com/[/url]

So I need a way to have a random quote appear in a table cell. I also want this table cell to adjust it’s size vertically to accomodate larger quotes, but I don’t want it’s width to adjust at all.

What would you say is the best way to do this?

to post a comment
Full-stack Developer

21 Comments(s)

Copy linkTweet thisAlerts:
@AlbatrossNov 12.2005 — Inside your table cell (the one you want the quotations to appear) enter the following code:

<i>
</i>&lt;?php

/**
* Add this line of code in your page:
* &lt;?php include "random_quote.php"; ?&gt;
*/

$quotes[] = "This is a quote";
$quotes[] = "This is another";
$quotes[] = "quote 3";
$quotes[] = "quote 4";
$quotes[] = "quote 5";
$quotes[] = "quote 6";

srand ((double) microtime() * 1000000);
$randomquote = rand(0,count($quotes)-1);

echo "&lt;p&gt;" . $quotes[$randomquote] . "&lt;/p&gt;";

?&gt;
Copy linkTweet thisAlerts:
@lord-of-shadowauthorNov 13.2005 — Thank you so much. That looks like it's exactly what I needed.
Copy linkTweet thisAlerts:
@AlbatrossNov 13.2005 — Yeah, you can either use it straight up (without the commented include) or put the script in its own separate file and call it from the include.

Sorry I forgot to mention that yesterday. I was going on four days with only 9 hours of sleep when I posted that.
Copy linkTweet thisAlerts:
@lord-of-shadowauthorNov 15.2005 — Don't worry about it. I understood what you meant, and I really appreciate it. Especially if you had such little sleep. In a similar position, helping random strangers over the internet is the last thing I'd be doing.

Thanks a bunch.
Copy linkTweet thisAlerts:
@lord-of-shadowauthorNov 26.2005 — One more question, if I may... The code you gave me works very nicely, at least when I've tested it. The only problem is, I can't have double quotation marks in the quote, because it screws up the code.

Is there any way to insert a " into the quote without the code interpreting it as the end of the quote?
Copy linkTweet thisAlerts:
@AlbatrossNov 26.2005 — try using a backslash character before the quotation mark

like this: "
Copy linkTweet thisAlerts:
@SheldonNov 27.2005 — oh the html special charactor for it [b]&quot;[/b]
Copy linkTweet thisAlerts:
@Sunny_GJan 13.2006 — Sorry to bring this thread back from the dead, but I also want to do the same thing for one of my sites. (http://www.team847.com/)

As some of you probably know, I know no PHP what-so-ever. The site I want to have the random quote generation for doesn't use PHP (it's just plain html & css).

How would I get this to work? Forgive me for being a PHP dummy.

-Thanks
Copy linkTweet thisAlerts:
@ray326Jan 13.2006 — Do a Google search for [B]+javascript +"random quote"[/B].
Copy linkTweet thisAlerts:
@Sunny_GJan 13.2006 — I want to stay away from javascript in this site.
Copy linkTweet thisAlerts:
@ray326Jan 13.2006 — Then you're done. HTML+CSS has no procedural capability and absolutely cannot generate anything randomly. (How's that for throwing down the gauntlet?)
Copy linkTweet thisAlerts:
@Sunny_GJan 14.2006 — PHP- all I ask for is a little help.

=after dinner=

What I want for my site made of html and css is to have a php script load a quote from a list of quotes (not in the html file). Can this be done?
Copy linkTweet thisAlerts:
@ray326Jan 14.2006 — Yep. That's what Albatross showed you. Of course you could Google that query I gave you replacing javascript with php.
Copy linkTweet thisAlerts:
@AlbatrossJan 17.2006 — PHP- all I ask for is a little help.

=after dinner=

What I want for my site made of html and css is to have a php script load a quote from a list of quotes (not in the html file). Can this be done?[/QUOTE]

PHP's output is mainly HTML.

All you need to do is slap the script where you want the HTML output to be and save the file with the .php extension. Then find a server capable of executing PHP files.
Copy linkTweet thisAlerts:
@Sunny_GJan 18.2006 — Lemmie just get clear.

I put that script in the HTML file and save it as PHP?

can't I just have the script as a seperate file that the HTML links to?
Copy linkTweet thisAlerts:
@Sunny_GJan 20.2006 — OK, I talked to the team and they liked the random quote idea, but they want it as a random image. They want it set up so a random image would load, but it would be a link to the full size version and under the image "Want to learn more" would be underneath and it would link to a page where they could learn more... can this be done with this same script?

If so, if the user clicks to see the full size version and then hits the back button, will that same image be there?
Copy linkTweet thisAlerts:
@xtecltdJan 20.2006 — im going to make it very easy fo ya mate

hear is the code just edit what you want it to say



<script language="Javascript"><!--

function text() {

};

text = new text();

number = 0;

// textArray

text[number++] = "<b><big>put anything hear...</big></big></b>."

text[number++] = "<b><big>or hear.............</big></big></big></b>."

text[number++] = "<b><big>or maybe hear.......</big></big></big></big></b>."

text[number++] = "<b><big>or even hear........</big></b>."

text[number++] = "<b><big>i like hear tho.....</big></big></big></b>."

text[number++] = "<b><big>hears nice also.....</big></big></big></big></b>."

// keep adding items here...

increment = Math.floor(Math.random() * number);

document.write(text[increment]);

//--></script>



hope that help mate
Copy linkTweet thisAlerts:
@Sunny_GJan 21.2006 — In my site I kinda want to stay away from Jscript.

I appreciate your help though.
Copy linkTweet thisAlerts:
@Sunny_GJan 21.2006 — How do you show images using this script when you can't use quotations?
Copy linkTweet thisAlerts:
@welshJan 21.2006 — this should work for the quote like:

"<img src=&quot;image.jpg&quot; alt=&quot;alternativ&quot;>"

edit: doesnt work trying to find out how
Copy linkTweet thisAlerts:
@Sunny_GJan 21.2006 — OK, I firgured it out (with the aid of one of our teams old members).

Instead of using " for the html part of the code, just use ' (single quotes).

The validatation says it's OK, so that's enough for me.

check it out! The cookie has the good validation.

http://www.team847.com/random.php
×

Success!

Help @lord-of-shadow spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...