Location: PHPKode > scripts > Quotations Database > quotations-database/admin/qotd_schedule.php
<?
/*
--------------------------------------------------
:::: Quotations Database ::::
--------------------------------------------------
PHP & MySQL application that stores quotations and author information, 
allows scheduling for 'quote of the day' and weekly themes.
Includes an administration interface to allow for easy updates and maintenance.
Copyright (C) 2009  Robert Temple
--------------------------------------------------

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

You can contact the author at hide@address.com
Please do not remove the author, copyright, or license info.
*/

// Initialize session and check to make sure user is registered and logged in
include "include/session.php"; 

// Connect  to database
include "include/connect.php";
dbconnect();

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
	<title> Select "Quote of the day"</title>	
    <link href="../quotation.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="700" border="0" align="center" cellpadding="1" cellspacing="0" bgcolor="#000000">
      <Tr>
        <Td>
<table width="698" border="0" align="center" cellpadding="1" bgcolor="#FFFFFF">
  <tr>
    <td bgcolor="#99CCFF"><span class="header">Quotations Schedule</span><br>
&nbsp;&nbsp;&nbsp;<a href="index.php">Admin page</a>&nbsp;>&nbsp;<a href="qotd_authors.php">Schedule a quotation</a><br>
&nbsp;
</td>
  </tr>
<Tr>
  <Td bgcolor="#cccccc"></Td>
</Tr>
 <Tr>
  <Td align="center" class="bodyBoldGrey"><?php echo "Today is ". date("l F d, Y, h:i A"); ?></Td>
</Tr>
<Tr>
  <Td bgcolor="#cccccc"></Td>
</Tr>

<tr><td><table align="center" width="600" border="0" cellpadding="4">
<tr>
<td class="bodyCopy">
<?php

// Select quotes scheduled after today's date:
$query = "SELECT * from FutureQuotesTBL WHERE QuoteDate > CURDATE() order by QuoteDate";	
	
	$result = mysql_query($query) or die ( mysql_error() );
	$num_rows = mysql_num_rows($result); 
	
			while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
			{
				$ID = $row["Id"];
				$QuotationId = $row["Quote"];
				$QuotationDate = $row["QuoteDate"];
				//  Change 2009-04-23 format to Tuesday, April 23, 2009:
				$date = new DateTime($row["QuoteDate"]);
				$phpdate = $date->format('l, F d, Y');
				
//Load the quotation from the database:
$todaysQuery = "SELECT * from QuotationsTBL where Id = $QuotationId";
$todaysResult = mysql_query($todaysQuery) or die ( mysql_error() );
while ($row = mysql_fetch_array($todaysResult, MYSQL_ASSOC))
			{
// If you want to crop the quotation to the first 70 characters, uncomment the next line and comment out the line after that:
//$todaysQuote = substr($row["Quotation"], 0, 70); //substr("abcdef", 0, 4); // will output "abcd"
$todaysQuote = $row["Quotation"];
$todaysAuthorId = $row["AuthorID"];
$todaysSource = $row["Source"];
$todaysMisc = $row["Misc"];

}
//Load author information from the database:
$todaysauthorQuery = "SELECT * from AuthorTBL where Id = $todaysAuthorId";
$todaysauthorResult = mysql_query($todaysauthorQuery) or die ( mysql_error() );

while ($row = mysql_fetch_array($todaysauthorResult, MYSQL_ASSOC))
			{
$authorFirstname = $row["Firstname"];
$authorLastname = $row["Lastname"];
$Author_Profession = $row["Profession"];
$Author_Country = $row["Country"];
$Author_DOB = $row["DOB"];

// If the author is 'anonymous' don't print first name, etc.:
if ($authorLastname == " Anonymous"){
echo "<span class=\"bodyBoldRed\">Scheduled for $phpdate</span>&nbsp;&nbsp;&nbsp;<a href=\"qotd_authors.php\">New quote for this date</a>&nbsp;&nbsp;&nbsp;<a href=\"delete_schedule_quote.php?ID=$ID\">Delete this schedule</a><br>";
echo "<span class=\"bodyCopy\">$todaysQuote</span><br>";
echo "<div align=\"right\" class=\"footerCopy\">$authorLastname</div><br>";
echo "<div align=\"right\" class=\"bodyCopy\"><em>$todaysSource</em></div><br><br>";
	} else {
echo "<span class=\"bodyBoldRed\">Scheduled for $phpdate</span>&nbsp;&nbsp;&nbsp;<a href=\"qotd_authors.php\">New quote for this date</a>&nbsp;&nbsp;&nbsp;<a href=\"delete_schedule_quote.php?ID=$ID\">Delete this schedule</a><br>";
echo "<span class=\"bodyCopy\">$todaysQuote</span><br>";
echo "<div align=\"right\" class=\"footerCopy\">$authorFirstname $authorLastname&nbsp;<em>&#8226; $Author_Profession &#8226; $Author_Country &#8226; $Author_DOB</em></div><br>";
echo "<div align=\"right\" class=\"bodyCopy\"><em>$todaysSource</em></div><br><br>";
	}
	}

				}
?>
				</td>
</tr>
</table>
<Tr>
  <Td align="center"><br>
&nbsp;</Td>
</Tr>        
  <Tr>
  <Td bgcolor="#cccccc">
</Td>
</Tr>
<Tr>
  <Td align="center"><br><br>
&nbsp;</Td>
</Tr>
</table>
</td>
  </tr>
</table>

</body>
</html>
Return current item: Quotations Database