<?php教程
session_start();
?>
<html>
<head>
<title>建站教學網php教程+access文章管理系統</title>
<meta HTTP-equiv="content-type" content="text/html; charset=gb2312" />
<style type="text/css教程">
body {
margin:0px;
text-align:center;
font-size:12px;
font-family:verdana;
}
td {
font-size:12px;
height:28px;
padding:4px;
font-family:verdana;
}
a:link,
a:visited,
a:active {
color: #005a17; text-decoration: none;
}
a:hover {
color: #ff5a00; text-decoration: underline;
}
</style>
</head>
<body>
<?php
//==================================
//連接資料庫教程
//==================================
@$conn = new com("adodb.connection");
$conn->open("driver={microsoft access driver (*.mdb)}; dbq=" . realpath("article.mdb"));
//==================================
//文章導航
//==================================
function article_menu(){
global $conn;
@$sql = "select * from list";
@$rs = $conn->execute($sql);
while(!$rs->eof){
echo "| <a href="?classid=" . $rs->fields[2]->value . "">" . $rs->fields[1]->value . "</a> ";
$rs->movenext();
}
echo "| <a href="?admin=login">後臺管理</a>rn";
$rs->close();
if(@$_session["articleadmin"] == "by_php_article"){
echo "<br />管理選項-> | <a href="?admin=class">分類管理</a> | <a href="?admin=insert">發表文章</a> | <a href="?admin=list">文章清單</a> | <a href="?admin=logout">退出登陸</a>";
}
}
//==================================
//文章清單:article_list(文章分類id)
//==================================
function article_list($str){
global $conn;
@$sql = "select id,by_title,by_name,by_time,by_count from article where by_class = " . $str . " order by id desc";
@$rs = $conn->execute($sql);
if(!$rs->eof){
echo "<table border="0" cellspacing="1" cellpadding="0" bgcolor="#cccccc">rn"
. " <tr bgcolor="#f3f3f3" align="center">rn"
. " <td>文章標題</td><td>文章作者</td><td>發表時間</td><td>流覽次數</td>rn"
. " </tr>rn";
while(!$rs->eof){
echo " <tr bgcolor="#ffffff">rn"
. " <td><a href="?artid=" . $rs->fields[0]->value . "">" . $rs->fields[1]->value . "</a></td><td>" . $rs->fields[2]->value . "</td><td>" . date("y-m-d h:i:s",$rs->fields[3]->value) . "</td><td>" . $rs->fields[4]->value . "</td>rn"
. " </tr>rn";
$rs->movenext();
}
echo "</table>rn";
}
else {
echo "<br />該分類不存在或暫時沒有任何文章!";
}
$rs->close();
}
//==================================
//文章詳細:article_look(文章id)
//==================================
function article_look($str){
global $conn;
@$sql = "select * from article where id = " . $str;
@$rs = $conn->execute($sql);
@$usql= "update article set by_count = (by_count + 1) where id = " . $str;
$conn->execute($usql);
if(!$rs->eof){
@$body = $rs->fields[5]->value;
$body = str_replace("[url=file://%22,%22%22,$body/]","",$body[/url]);
echo "<table border="0" width="60%" cellspacing="1" cellpadding="0" bgcolor="#cccccc">rn"
. " <tr bgcolor="#f3f3f3" align="center">rn"
. " <td style="font-size:14px;font-weight:bold">" . $rs->fields[1]->value . "</td>rn"
. " </tr>rn"
. " <tr bgcolor="#f3f3f3" align="center">rn"
. " <td>文章作者:" . $rs->fields[2]->value . " | 發表時間:" . date("y-m-d h:i:s",$rs->fields[3]->value) . " | 流覽次數:" . $rs->fields[4]->value . "</td>rn"