多数据表共用一个页的新闻发布

2016-01-29 14:57 2 1 收藏

多数据表共用一个页的新闻发布,多数据表共用一个页的新闻发布

【 tulaoshi.com - PHP 】

  本文为了简单并能够说明主要内容,一些次要的html内容相对简单。
在网站有多个内容要在某一页显示时可在网页中共用一个显示和提交。
本例中有两个数据表(news,ctm);一个主页(index.php);
一个提交页(index_pub.php;和一个包函页(index_view.php)
一个子页(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---
<?ph
$query="select * from ".$name." order by id desc limit 0,5;
$result=mysql_query($query,$db);
if ($result){
while($myrow=msyql_fetch_array($result)){
?
<tr<td<a href="view_d.php?recod=<?php echo $myrow[id]; ?&name=<?php echo $name; ?"$myrow[title]</a</td</tr
<?php
  }
}
else{
echo "这里还没新的内容。";}
?


----index.php---
<?php
$id=mysql_connect("localhost","username","password");
$db=mysql_select_db("your_db",$id);
?
<html
<body
<hr size=0 color=green width=100%
<p align=left<font color=green size=+3Yourname Online</font</p
<hr size=3 color=green width=100%
<p align=left<font size=-1你现在的位置--首页</font</p
<hr size=2 color=green width=100%
<table width=100 border=0 cellpadding=0 cellspacing=0
  <tr
<!-- news --
    <td width=50% align=left
      <table width=100 border=0 cellpadding=0 cellspacing=0
        <?php
           $name=news;
           include("index_view.php");
        ?
      </table
    </td
<!-- ctm --
    <td width=50% align=left
      <table width=100 border=0 cellpadding=0 cellspacing=0
        <?php
           $name=ctm;
           include("index_view.php");
        ?
      </table
    </td
  </tr
</table
<hr size=0 width=100% color=green
<p align=center<font size=-1Copyrignt 1999…</font</P
</body
</html

----index_pub.php---
<?php
$id=mysql_connect("localhost","username","password");
$db=mysql_select_db("your_db",$id);
?
<html
<body
<form action=index_view.php method=post
  <p请选择数据库:<br
  <select name=db_name size=1
    <option value=newsnews</option
    <option value=ctmctm</option
  </select</p
  <p标题:<br
  <input type=text name=title size=20</p
  <p内容:<br
  <textarea rows=6 cols=10 name=detail</textarea</p
  <p<input type=submit value=submit</p
</form
<?php
switch ($db_name){
   case news:$name=news;
   break;
   case ctm:$name=ctm;
&

来源:https://www.tulaoshi.com/n/20160129/1494839.html

延伸阅读
标签: excel
Excel如何批量制作CSV数据表   众所周知,Excel的功能十分强大,而其最核心的功能在于数据处理。熟练驾奴Excel,您的工作将充满快乐和自信。当您仅花上几分钟就完成了别人花上几天功夫才能完成的数据处理工作时,心中的那份喜悦只有您自己才能体会得到!下面给大家展示的是Excel批量制作数据表 目的 1通过数据模板与VBA结...
截断操作的SQL语法如下。 ――――――――――――――――――――――――――――――――――――― TRUNCATE TABLE 用户名.表名 [DROP|REUSE STORAGE] ――――――――――――――――――――――――――――――――――――― 其中,若使用DROP STORAGE子句,显式指明释放数据表和索引的空间。若使用REUSE...
要创建的两个数据表 1. 研究生信息表 表名:scott.student。 表结构如表7.6所示。 3. 两个数据表的关系 导师信息表(scott.director)的主码DIRECTOR_ID是研究生信息表(scott.student)的外码。也就是说,当导师信息表的DIRECTOR_ID字段发生变化时,研究生信息表的字段DIRECTOR_ID也会随之自动发生变化。 ...
数据表的删除比较简单,表删除后其占用的空间就被系统释放和回收,表的删除是无法回滚的操作。可删除的内容包括。 表的定义 表中的数据 表中的索引 表中的约束条件 表上的触发器 表中的权限 在里删除表 (1)如图7.35所示。 (2)出现如图7.36所示界面。 (3)对应上述删除数据表director的SQL代码为...
    工作中常遇到二维表的存储及定位问题,通常我们会用EXCEL来存储,在数据库中如何实现二维表的存储和定位呢?首先,我们建立二维表,以下二维表为例 二维表  直径 0-300 300-500 500-1000 1000-1500 160.5  0.80.9 0.6 40 0.7 1.0 1.1 1.2&nbs...

经验教程

407

收藏

61
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部