Okay - so I found a thread on random quote block in the old PHPNuke forums. Someone wanted a random quote block, someone else said, try this:
Code:
<?
$content = "";
$title = "Quote by:";
mt_srand((double)microtime()*1000000);
$total = mysql_fetch_array(mysql_query("SELECT COUNT(qid) AS total FROM quotes"));
$tot = ($total[total]);
$p = ($tot+1);
while ($p>$tot){
$p = mt_rand(0,($total[total] - 1));
//mysql_select_db ("$dbname") or die ("Could not select database");
$query = ("SELECT * FROM quotes where qid = $p ");
$result = mysql_query ($query) or die ("Query failed1");
$r = mysql_num_rows($result);
//set_time_limit(0);
$row = mysql_fetch_object ($result);
}
$sl = strlen($row->quote);
if ($sl>2){
$content = "
$row->quote
$title
$row->author";
$content .= "<hr><center>There are $tot
quotes in the database.</center>";
$content .= "<center>and this is no: $p</center>";
} else {
// this is what we say when the quotes database is empty
$content = 'It is NOT what you know,
but to know where to find it';
}
mysql_free_result ($result);
?>
Now, I know you'd have to actually create a quotes database, and I'm not entirely sure how to do that, so I could use help with it, and also - would I just save the above as quotes.php, and stick it in html/blocks ?
I figured out a work-around, which is sort of tedious but it serves my purpose - I used the Cafepress block, took out all the links, then just saved my taglines (which I wanted to come up randomly whenever the page was reloaded) as transparent gif files. You can't actually tell that it's not real text. But if you wanted hundreds of quotes, that solution wouldn't work for you.
chris-au Elite Nuker
Joined: Jan 31, 2003
Posts: 717
Posted:
Sun Aug 10, 2003 11:16 pm
That is a block thst I hacked/wrote and put in a thread to help somebody.
I do have a database with over 11000 quotes and on each page transition it will diplay another quote.
Here is a small sample of the sql file:
# phpMyAdmin MySQL-Dump
# version
#
# http://phpmyadmin.sourceforge.net/ (download page)
#
# Host: localhost
# Generation Time: Mar 30, 2002 at 08:58 AM
# Server version: 3.23.33
# PHP Version: 4.0.6
# Database :
# --------------------------------------------------------
#
# Table structure for table `nuke_quotes`
#
DROP TABLE IF EXISTS nuke_quotes;
CREATE TABLE nuke_quotes (
qid int(10) unsigned NOT NULL auto_increment,
quote text,
author varchar(150) NOT NULL default '',
PRIMARY KEY (qid)
) TYPE=MyISAM;
#
# Dumping data for table `nuke_quotes`
#
INSERT INTO nuke_quotes VALUES (1, '"Be yourself" is about the worst advice you can give to people. ', 'Tom Masson');
INSERT INTO nuke_quotes VALUES (2, '"Hello," he lied. ', 'Don Carpenter, quoting a Hollywood agent');
INSERT INTO nuke_quotes VALUES (3, '"Home, Sweet Home" must surely have been written by a bachelor. ', 'Samuel Butler');
That is a block thst I hacked/wrote and put in a thread to help somebody.
I do have a database with over 11000 quotes and on each page transition it will diplay another quote.
Code:
Here is a small sample of the sql file:
# phpMyAdmin MySQL-Dump
# version
#
# http://phpmyadmin.sourceforge.net/ (download page)
#
# Host: localhost
# Generation Time: Mar 30, 2002 at 08:58 AM
# Server version: 3.23.33
# PHP Version: 4.0.6
# Database :
# --------------------------------------------------------
#
# Table structure for table `nuke_quotes`
#
DROP TABLE IF EXISTS nuke_quotes;
CREATE TABLE nuke_quotes (
qid int(10) unsigned NOT NULL auto_increment,
quote text,
author varchar(150) NOT NULL default '',
PRIMARY KEY (qid)
) TYPE=MyISAM;
#
# Dumping data for table `nuke_quotes`
#
INSERT INTO nuke_quotes VALUES (1, '"Be yourself" is about the worst advice you can give to people. ', 'Tom Masson');
INSERT INTO nuke_quotes VALUES (2, '"Hello," he lied. ', 'Don Carpenter, quoting a Hollywood agent');
INSERT INTO nuke_quotes VALUES (3, '"Home, Sweet Home" must surely have been written by a bachelor. ', 'Samuel Butler');
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum