Forum Moderators: coopster

Message Too Old, No Replies

List array?

A general query!

         

ahmedtheking

8:35 pm on Dec 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi peeps! Ive got a small query! Ive written a script that randomly echos a set of quotes (as shown below). However, i want this script, when a variable called 'quotesvar' is true, to echo all the scripts, like a foreach or while loop.

I thought about putting the quotes into an array, but didn't know how to go about it!

Heres the script below:

<?php
$quotes[] = "The main purpose of the site was to have something where people can check us out and hopefully hire us! But somecompany took it a stage further, they promoted us in so many ways that we are getting requests
for gigs on a daily basis! If it wasn&#8216;t for somecompany, we would probably all be working in Mc Ds!¦cl¦Rob Drake, Clarity";
$quotes[] = "Our organisation needed a base where we could start our campaign from. somecompany helped us find the best solution for us in terms of a website. They created a full CMS system so that we could have site members posting new news as well as guests registering their comments. Their performance and understanding of the subject is fantastic. They presented many concepts to us and help us find the right one for us¦ocnd¦Tahrir Swift, Orpington CND";

if ($quotesvar)
{

// query....?

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

$bits = explode('¦',$quotes[$randomquote]);

echo '<span class="quote">&quot;...'.$bits[0].'...&quot; - <a accesskey="q" href="/index.php?goto=cl_'.$bits.'" title="'.$bits[2].'">'.$bits[2].'</a></span>';
}
?>

Any thanks will be appreciated!

[1][edited by: jatar_k at 11:32 pm (utc) on Dec. 17, 2004]
[edit reason] generalized company name [/edit]

jatar_k

11:36 pm on Dec 17, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you could drop them in a db, put them in a file, load them into an array

I don't think it really matters, though my first thought would be db. Use unique id's and select the count and randomly pick an id and select the content for that id from the db.

ahmedtheking

1:17 am on Dec 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I thought that would be the best idea! thanks!