News release with multiple data tables sharing one page_PHP tutorial
WBOYOriginal
2016-07-21 16:06:33943browse
In order to keep this article simple and explain the main content, some secondary HTML content is relatively simple. When the website has multiple contents to be displayed on a certain page, one display and submission can be shared in the web page. In this example, there are two data tables (news, ctm); a homepage (index.php); a submission page (index_pub.php; and a package page (index_view.php) a Subpage (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)){ ?>
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";} ?>
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."
"; echo "
内容:".$detail."
"; } else{echo "此文件已被删除!";}
http://www.bkjia.com/PHPjc/315359.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/315359.htmlTechArticleIn order to be simple and able to explain the main content, some secondary html content is relatively simple in this article. When the website has multiple contents to be displayed on a certain page, one display and submission can be shared in the web page. ...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn