This is an old revision of the document!
First, create a table in the DB that will hold all of your quotes. In our case, we wanted the quote, the author, a link to the author, and the date it was added, so a query like this did fine.
CREATE TABLE `quotes` ( `quotes_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `quotes_text` TEXT NOT NULL , `quotes_author` TEXT NOT NULL , `quotes_link` VARCHAR(255) NOT NULL, `quotes_active` INT NOT NULL DEFAULT 0, `quotes_date_added` DATE NOT NULL ) ENGINE = MYISAM ;
Pro tip: VARCHAR(255) is used commonly for things like URLs, but in reality some URLs are longer than 255 characters. Make sure you don't allow URLs that are too long to store, or else make this field bigger.
You can go ahead and insert some quotes in this stage if you like.
Find the place in the template where you'd like to insert the random quote, and add these lines:
$quote_sql = $db->Execute("SELECT * from quotes WHERE quotes_active = 1 ORDER BY RAND() LIMIT 1;"); $quote_content = '<div>"' . stripslashes($quote_sql->fields['quotes_text']) . '"</div> <br /><div> - <a href="'.stripslashes($quote_sql->fields['quotes_link']).'" target="_blank">' . stripslashes($quote_sql->fields['quotes_author']). '</div></a></div>'; echo $quote_content;
Obviously you should modify this to match your own template, and add whatever css would make it look good.