PHP实现图书信息显示

一 数据库脚本

  1. create database db_book;
  2. use db_book;
  3. create table db_book
  4. (
  5. id INT NOT NULL AUTO_INCREMENT,
  6. bookname varchar(50)notnull,
  7. author varchar(20),
  8. price int,
  9. bookpublic varchar(50),
  10. pubtime date notnull,
  11. PRIMARY KEY (id)
  12. );
  13. insert into db_book values(1,"明日之星","大神",20,"明日之星出版社","2016-12-12");
二 PHP脚本
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>图书信息显示</title>
<link rel="stylesheet" type="text/css" href="css/font.css">
</head>
<body topmargin="0" leftmargin="0" bottommargin="0">
<table width="703" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td  bgcolor="#EF5E0F" ><table width="703" border="0" align="center" cellpadding="0" cellspacing="1">
      <tr>
        <td height="25" colspan="5" bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
      <tr>
        <td width="187" height="25" bgcolor="#F39A40"><div align="center">书名</div></td>
        <td width="173" bgcolor="#F39A40"><div align="center">作者</div></td>
        <td width="101" bgcolor="#F39A40"><div align="center">价格</div></td>
        <td width="131" bgcolor="#F39A40"><div align="center">出版社</div></td>
        <td width="105" bgcolor="#F39A40"><div align="center">出版时间</div></td>
      </tr>
	  <?php
	  $conn=mysql_connect("localhost","root","root");
	  mysql_select_db("db_book",$conn);
	  mysql_query("set names gb2312");
	  $sql=mysql_query("select * from db_book order by id desc",$conn);
	  $info=mysql_fetch_array($sql);
	   if($info==false)
	    {
		  echo "暂无图书信息!";
		}
		else
		{   
		  do
		   {
	  ?>
      <tr>
        <td height="25" bgcolor="#FFFFFF"><div align="center"><?php echo $info[bookname];?></div></td>
        <td height="25" bgcolor="#FFFFFF"><div align="center"><?php echo $info[author];?></div></td>
        <td height="25" bgcolor="#FFFFFF"><div align="center"><?php echo $info[price];?></div></td>
        <td height="25" bgcolor="#FFFFFF"><div align="center"><?php echo $info[bookpublic];?></div></td>
        <td height="25" bgcolor="#FFFFFF"><div align="center"><?php echo $info[pubtime];?></div></td>
      </tr>
	  <?php
	      }while($info=mysql_fetch_array($sql));  
		}
	  
	  ?>
    </table></td>
  </tr>
</table>
</body>
</html>
 
三 运行结果

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值