It took a day to write a php access operation demo whole site sample program (excluding paging and secondary classification)
The code is as follows:
Session_start ();
// ==================================
// Author: biyuan
// Time: 2006.07
// Contact: QQ6010707
// ==================================
?>
Biyuan Network PHP + ACCESS article management system
// ==========================================
// Connect to the database
// ==========================================
@ $ Conn = new com ("ADODB. Connection ");
$ Conn-> Open ("DRIVER = {Microsoft Access Driver (*. mdb)}; DBQ =". realpath ("article. mdb "));
// ==========================================
// Article navigation
// ==========================================
Function article_menu (){
Global $ conn;
@ $ SQL = "Select * From List ";
@ $ Rs = $ conn-> Execute ($ SQL );
While (! $ Rs-> Eof ){
Echo "| Fields [2]-> value." \ ">". $ rs-> Fields [1]-> value ."";
$ Rs-> MoveNext ();
}
Echo "| background management \ r \ n ";
$ Rs-> Close ();
If (@ $ _ SESSION ["ARTICLEADMIN"] = "BY_PHP_ARTICLE "){
Echo"
Manage Options-> | category management | Post | article list | log out ";
}
}
// ==========================================
// Article List: article_list (document Category 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"
\ R \ n"."
\ R \ n"."
Article title |
Author |
Posting time |
Browsing times | \ R \ n"."
\ R \ n ";While (! $ Rs-> Eof ){Echo"
\ R \ n"."
Fields [0]-> value. "\"> ". $ rs-> Fields [1]-> value ." |
". $ Rs-> Fields [2]-> value ." |
". Date (" Y-m-d H: I: s ", $ rs-> Fields [3]-> value )." |
". $ Rs-> Fields [4]-> value ." | \ R \ n"."
\ R \ n ";$ Rs-> MoveNext ();}Echo"
\ R \ n ";
}
Else {
Echo"
This category does not exist or there are no articles for the time being! ";
}
$ Rs-> Close ();
}
// ==========================================
// Article Details: article_look (Article 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"
\ R \ n"."
\ R \ n"."
". $ Rs-> Fields [1]-> value ." | \ R \ n"."
\ R \ n"."
\ R \ n"."
Author :". $ rs-> Fields [2]-> value. "| posting time :". date ("Y-m-d H: I: s", $ rs-> Fields [3]-> value ). "| browsing times :". $ rs-> Fields [4]-> value." | \ R \ n"."
\ R \ n"."
\ R \ n"."
". $ Body ." | \ R \ n"."
\ R \ n"."
\ R \ n"."
[Back] [print] [close] | \ R \ n"."
\ R \ n"."
\ R \ n"
."