• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

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

发布: 2007-7-01 15:06 | 作者: admin | 来源: | 查看: 12次 | 进入软件测试论坛讨论

领测软件测试网 <?
/*
  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>

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备2023014753号-2
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网