Multi-data tables share one page of news publishing, read multi-data tables share one page of news publishing, this article to be simple and can describe the main content, some secondary html content is relatively simple. When the website has multiple content to be displayed on a page, you can use one display and submit on the page. In this example, there are two data tables (news, ctm) and one home page (index. php); 1 "> <LINKhref =" http: // www in this article, some secondary html content is relatively simple to simplify and describe the main content.
When the website has multiple content to be displayed on a page, you can use one display and submit on the page.
In this example, there are two data tables (news, ctm) and one home page (index. php );
One submission page (index_pub.php; and one package page (index_view.php)
A child page (view_d.php ).
---- News, ctm ---
Increate table news (id int (80) not null auto_increment, title char (100), detail text, primay key (id ));
Increate table ctm (id int (80) not null auto_increment, title char (100), detail text, primay key (id ));
---- Index_view.php ---
$ Query = "select * from". $ name. "order by id desc limit 0, 5;
$ Result = mysql_query ($ query, $ db );
If ($ result ){
While ($ myrow = msyql_fetch_array ($ result )){
?>
& Name = "> $ Myrow [title]
}
}
Else {
Echo "there is no new content yet. ";}
?>
---- Index. php ---
$ Id = mysql_connect ("localhost", "username", "password ");
$ Db = mysql_select_db ("your_db", $ id );
?>
Yourname Online
Your current location --> homepage
$ Name = news;Include ("index_view.php ");?>
|
$ Name = ctm;Include ("index_view.php ");?>
|
Copyrignt 1999...
---- Index_pub.php ---
$ Id = mysql_connect ("localhost", "username", "password ");
$ Db = mysql_select_db ("your_db", $ id );
?>
Switch ($ db_name ){
Case news: $ name = news;
Break;
Case ctm: $ name = ctm;
Break;
}
$ Query = "insert into". $ name. "(title, detail) values ('$ title',' $ detail ');
$ Result = mysql_query ($ query, $ db );
If ($ result) {echo "OK ";}
Else {echo "failed ";}
?>
---- View_d.php ---
$ Id = mysql_connect ("localhost", "username", "password ");
$ Db = mysql_select_db ("your_db", $ id );
?>
If ($ recod ){
$ Query = "select * from". $ name. "where id =". $ recod;
$ Result = mysql_query ($ query, $ db );
$ Title = mysql_result ($ result, 0, title );
$ Detail = mysql_result ($ result, 0, detail );
Echo"
Title: ". $ title ."
";
Echo"
Content: ". $ detail ."
";
}
Else {echo "This file has been deleted! ";}