Get best price on Unlocked Samsung Galaxy A21 | ||||||||||||
|
||||||||||||
|
PHP Script: Quote of the DayThis free PHP script for "Quote of the Day" automatically updates your web site with randomly selected content. It this case, the content is a quote. You can
easily vary the content for your own needs.
Tutorial for Quote of the Day PHP ScriptMy first thought was to use PHP and MySQL. A PHP date function would key off the current date and select the same
quote throughout the day. The next day, it would randomly select a new quote. I thought about using MySQL to store the quotes
and author data and use PHP to dynamically display the day's quote.
A BIG shoutout to trishah.com for finding a error in the following and letting me know. I fixed it. Apologies to anyone I caused to go crazy getting it to work. (Updated January 24, 2018) Source Code Files for Quote of the Day PHP ScriptThere are 4 files for "Quote of the Day"
Data File With the Quotes (quoteData.txt)The file that contains all the quotes is a simple text file. One line for each quote and related data such as author.. The file
can include HTML tags for formatting if you wish. Just be sure each line (that is, each quote) has the formatting you want.
Current Day's Quote (quoteToday.txt)This file contains only one quote, the quote displayed that day. This file is updated daily by your server. Create the file and make it writable. Change permissions (CHMOD) to "646" so the server can save the changes. (646 permissions look like-rw-r--rw- ).
Here is sample quoteToday.txt file (today's quote) to work with. The file has one line, the content that is displayed that day. Web Page That Displays the QuoteThe web page where you display the quote contains the PHP code that opens, reads and inserts the contents of the quoteToday.txt file.
<?php
// display quote of the day $file = "quoteToday.txt"; $fh = fopen($file, "r"); $string = fread($fh, filesize($file)); fclose($fh); echo "<p>$string</p>"; ?> Name the file whatever you want. File the Cron Job Runs (quoteGenerate.php)Here is the quoteGenerate.php file to download. Save the file with a "PHP" extension. Modify the text in any text editor. Upload the file to your web server and set up your cron job. The internet and your hosting provider have lots of help for setting up cron jobs. You can even start with wikipedia. Fixing Common ProblemsUpload all 4 files to your web server.
Thanks for visiting and I hope you find this helpful. I have used this code of a number of sites.
|
privacy policy || © 1997-2016. astonishinc.com All Rights Reserved. |