Log in

View Full Version : [How do I?] Run a script and show it in a template


Murphinator
04-16-2005, 11:13 PM
I'm using the side bar for my website http://teenstoteens.com

I have a random quote script that I want to use in the side bar. The problem I'm having is that I don't know how to run the script in global.php and show it in the template.

The script in global.php is:

$query = "SELECT quote " .
"FROM quote " .
"WHERE disp = '1' " .
"ORDER BY RAND() " .
"LIMIT 1";
$results = mysql_query($query)
or die(mysql_error());

while ($row = mysql_fetch_array($results)) {
$quote = $row['quote'];
}

And in the template I have:

<td class="alt1">$quote</td>


So how do I make it actually show up?

Help please.

This is easy!

nexialys
04-20-2005, 10:06 PM
$quote = $DB_site->query_first("
SELECT quote FROM ".TABLE_PREFIX."quote
WHERE disp = '1'
ORDER BY RAND() LIMIT 1
");
will give you your result...