选择显示字体大小

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


  本文为了简单并能够说明主要内容,一些次要的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
&#36;query=&quot;select * from &quot;.&#36;name.&quot; order by id desc limit 0,5;
&#36;result=mysql_query(&#36;query,&#36;db);
if (&#36;result){
while(&#36;myrow=msyql_fetch_array(&#36;result)){
?>
<tr><td><a href=&quot;view_d.php?recod=<?php echo &#36;myrow[id]; ?>&name=<?php echo &#36;name; ?>&quot;>&#36;myrow[title]</a></td></tr>
<?php
  }
}
else{
echo &quot;这里还没新的内容。&quot;;}
?>


----index.php---
<?php
&#36;id=mysql_connect(&quot;localhost&quot;,&quot;username&quot;,&quot;password&quot;);
&#36;db=mysql_select_db(&quot;your_db&quot;,&#36;id);
?>
<html>
<body>
<hr size=0 color=green width=100&#37;>
<p align=left><font color=green size=+3>yourname online</font></p>
<hr size=3 color=green width=100&#37;>
<p align=left><font size=-1>你现在的位置-->首页</font></p>
<hr size=2 color=green width=100&#37;>
<table width=100 border=0 cellpadding=0 cellspacing=0>
  <tr>
<!-- news -->
    <td width=50&#37; align=left>
      <table width=100 border=0 cellpadding=0 cellspacing=0>
        <?php
           &#36;name=news;
           include(&quot;index_view.php&quot;);
        ?>
      </table>
    </td>
<!-- ctm -->
    <td width=50&#37; align=left>
      <table width=100 border=0 cellpadding=0 cellspacing=0>
        <?php
           &#36;name=ctm;
           include(&quot;index_view.php&quot;);
        ?>
      </table>
    </td>
  </tr>
</table>
<hr size=0 width=100&#37; color=green>
<p align=center><font size=-1>copyrignt 1999…</font></p>
</body>
</html>

----index_pub.php---
<?php
&#36;id=mysql_connect(&quot;localhost&quot;,&quot;username&quot;,&quot;password&quot;);
&#36;db=mysql_select_db(&quot;your_db&quot;,&#36;id);
?>
<html>
<body>
<form action=index_view.php method=post>
  <p>请选择数据库:<br>
  <select name=db_name size=1>
    <option value=news>news</option>
    <option value=ctm>ctm</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 (&#36;db_name){
   case news:&#36;name=news;
   break;
   case ctm:&#36;name=ctm;
   break;
}
&#36;query=&quot;insert into &quot;.&#36;name.&quot;(title,detail) values('&#36;title','&#36;detail');
&#36;result=mysql_query(&#36;query,&#36;db);
if (&#36;result){echo &quot;ok&quot;;}
else{echo &quot;failed&quot;;}
?>
</body>
</html>

----view_d.php---
<?php
&#36;id=mysql_connect(&quot;localhost&quot;,&quot;username&quot;,&quot;password&quot;);
&#36;db=mysql_select_db(&quot;your_db&quot;,&#36;id);
?>
<html>
<body>
<?php
if (&#36;recod){
   &#36;query=&quot;select * from &quot;.&#36;name.&quot; where id=&quot;.&#36;recod;
   &#36;result=mysql_query(&#36;query,&#36;db);
   &#36;title=mysql_result(&#36;result,0,title);
   &#36;detail=mysql_result(&#36;result,0,detail);
   echo &quot;<p>标题:&quot;.&#36;title.&quot;</p>&quot;;
   echo &quot;<p>内容:&quot;.&#36;detail.&quot;</p>&quot;;
}
else{echo &quot;此文件已被删除!&quot;;}
</body>
</html


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons