Press Release System (example) one News

Source: Internet
Author: User
Tags date format header include mysql query mysql database
?
/*
News Donkey v1.0 d8b DB d88888b db d8b db. d8888.
by Oscar Rylin [oscar@mgon.com] 888o ' i8i ' YP
88v8o 88ooooo i8i ' 8bo.
V8o88 88~~~~~ Y8 i8i ' y8b.
V888 88. ' 8b D8 ' 8b D8 ' db 8D
VP v8p y88888p ' 8b8 ' 8d8 ' 8888Y '


d8888b.  . d88b. D8B DB DB DD d88888b DB db
The ' 8D. 8P Y8. 888o, 8P ' ' 8b D8 '
88v8o 88,8p 88ooooo ' 8bd8 '
The V8o88 8b 88~~~~~ 88
8D ' 8b D8 ' V888 88 ' 88. 88.88
y8888d ' y88p ' VP v8p YP YD y88888p YP

This script is made by Oscar Rylin (oscar@mgon.com) while learning PHP w/
MySQL connections.

What the script does:
* Provides an easy way to Read news from a MySQL database
* Prints it out in a nice HTML format which is customizable
* Provides a secure interface (User/password validation through a MySQL db)
* Updating news, deleting and adding users and lots of other stuff
*/

Include "dbconn.php"; This is http://zend.com/codex.php?id=35&single=1
Include "settings.php"; The settings file
?>

<title>newsM0nger1.0</title>
<style type= "Text/css" >
. section {font-weight:bold; font-size:10pt;}
. newstxt {font-weight:normal; font-size:10pt; color: #ffffff; font-family:verdana;}
a {font-weight:bold; font-size:10pt; color: #ffffff; font-family:verdana;}
a.normal {font-weight:bold; font-size:10pt; color: #000000; font-family:verdana;}
</style>
<body bgcolor= "White" >
? Print $header;?>
<center>
<table border= "1" cellpadding= "0" cellspacing= "0" bordercolor= "BLACK" >

?

$db = mysql_connect ($dbHost, $dbUser, $dbPass);
mysql_select_db ($dbName, $db);
$result = mysql_query ("SELECT count (ID) as total from News", $DB);
$row = Mysql_fetch_array ($result);
Mysql_close ($DB);

if ($row [Total] > 5) {
$pCount = 0;
print "<b>Archive</b>";
Print "<a href=\" $PHP _self?start=0\ "class=\" normal\ ">Main</a>";
while ($pCount < ($row [TOTAL]/5)-1) {
+ + $pCount;
Print "<a href=\" $PHP _self?start=. ($pCount *5). " \ "class=\" normal\ "> $pCount </a>";
}
}

$tmpDL = 0;

$sql = new Cdbmysql ($dbHost, $dbUser, $dbPass, $dbName);
if ($start) {
$sql-> Query ("SELECT * from news WHERE ID <".) ($row [Total]-$start). "ORDER by ID DESC");
} else {
$sql-> Query ("SELECT * from news ORDER by ID DESC");
}

while ($sql-> readrow ()) && ($tmpDL < $newsDL)) {

$id = ($sql-> rowdata["id"]);
$date = ($sql-> rowdata["date"]);
$poster = ($sql-> rowdata["user");
$header = ($sql-> rowdata["header"]);
$news = ($sql-> rowdata["News");
$news = NL2BR ($news);

$uDB = new Cdbmysql ($dbHost, $dbUser, $dbPass, $dbName);
$uDB-> Query ("SELECT * from Users where user=\" $poster \ ");

while ($uDB-> Readrow ()) {
$email = ($uDB-> rowdata["email"));
}
$uDB-> Close ();

$format = "

<tr>
&LT;TD width=\ "579\" height=\ "20\" background=\ "section.gif\" class=\ "section\" colspan=\ "2\" >
<font color=\ "white\" > $date </font>-<font color=\ "#003366 \" > $header </font>
</td>
</tr>

<tr>
&LT;TD bgcolor=\ "#666688 \" class=\ "newstxt\" colspan=\ "2\" >
$news
<br>
--<a href=\ "mailto: $email \" > $poster </a>
</td>
</tr>

<tr>
&LT;TD bgcolor=\ "#ffffff \" height=\ "20\" colspan=\ "2\" >
</td>
</tr>
";
print "$format";
+ + $tmpDL;
}
$sql-> Close ();
?>
</table>
<table border= "0" cellpadding= "0" cellspacing= "0" width= "579" >
&LT;TR&GT;&LT;TD width= "50%" align= "left" ></td> &LT;TD width= "50%" align= "right" ></td></tr >
</table>
</center>
? Print $footer;?>
</body>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.