动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
  
   PHP → 阅读文章

 新闻发布系统 (例子) 一 news

作者来源: 
阅读 数 538 人次 , 2006-3-29 4:10:00 


<?
/*
news donkey v1.0 d8b  db d88888b db  d8b  db .d8888.
by oscar rylin [oscar@mgon.com]  888o 88 88'  88  i8i  88 88' yp
88v8o 88 88ooooo 88  i8i  88 `8bo.  
88 v8o88 88~~~~~ y8  i8i  88  `y8b.
88 v888 88.  `8b d8'8b d8' db  8d
vp  v8p y88888p `8b8' `8d8' `8888y'
 
 
d8888b. .d88b. d8b  db db  dd d88888b db db
88 `8d .8p y8. 888o 88 88 ,8p' 88'  `8b d8'
88  88 88 88 88v8o 88 88,8p  88ooooo `8bd8'
88  88 88 88 88 v8o88 88`8b  88~~~~~ 88
88 .8d `8b d8' 88 v888 88 `88. 88. 88
y8888d' `y88p' vp  v8p yp  yd y88888p yp

this script was 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
?>

<html>
<head>
<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>
</head>
<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>
<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>
<td bgcolor=\"#666688\" class=\"newstxt\" colspan=\"2\">
$news
<br>
-- <a href=\"mailto:$email\">$poster</a>
</td>
</tr>

<tr>
<td bgcolor=\"#ffffff\" height=\"20\" colspan=\"2\">
</td>
</tr>
";
 print "$format";
 ++$tmpdl;
}
//$sql -> close();
?>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="579">
 <tr><td width="50%" align="left"><img src="php.gif"></td><td width="50%" align="right"><img src="mysql.gif"></td></tr>
 </table>
</center>
<? print $footer; ?>
</body>
</html>

 
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:新闻发布系统 (例子) 二 dbconn
· 下一篇:PHP也可以當成Shell Script
· 使用GeoIP和PHP构建一个简单的MySQL地理数据库
· 两个日期类
· 字符串处理函数库
· 自定义PHP分页函数
· window.open()的所有参数列表


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077