<?
/////////////////////////////////////////////
//
// Sample email script
//
// This will email the contents of the news
// database to the address. If you wish to
// add functions to this please let us know.
//
///////////////////////////////////////////////
require ("bb_news_config.inc");
mysql_connect($bb_news_hostname,$bb_news_mysqluser,$bb_news_mysqlpassword)
or die("Unable to connect to SQL server"); // We do this to handle the errors
// news is the name of the table
//
// We select only 5 of the latest records here, ordered by id number. You can change that
// to any number you would like or you can take it out all together
//
//
// Change this to where new=yes to get only the latest articles
//
$query = "select id, subject, news, date_format(date, '%c/%e/%Y') as date, author, link from news
order by id desc";
$news = mysql_db_query($bb_news_db, $query) or die("Select Failed!");
// We do this untill there is nothing left to do in the select statment.
//
$contents = "";
while ($row = mysql_fetch_array($news)) {
// Formating is completly up to you. This is a sample.
//
// Color settings are in config.inc
//
$contents = $contents . $row['date'];
$contents = $contents . "\n";
$contents = $contents . $row['author'];
$contents = $contents . "\n";
$contents = $contents . $row['subject'];
$contents = $contents . "\n";
$contents = $contents . $row['news'];
$contents = $contents . "\n";
$contents = $contents . $row['link'];
$contents = $contents . "\n\n";
// Now we are done. Simple call this file from within your php3 app useing
// require ("bb_news.php3"); in your code. Dont forget to include the open and close php
}
//You can add your from email and then the list for to.
$from_header = "From: hide@address.com";
$to = "hide@address.com";
mail($to, $subject, $contents, $from_header);
// To test out the output
echo $contents;
?>