PHP+access簡單實用的文章管理程式碼

來源:互聯網
上載者:User
關鍵字 網路程式設計 PHP教程

<?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"

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.