PHP+MySQL 利用mysql_fetch_row模糊查询图书信息
来源:互联网 发布:淘宝上注册商标靠谱吗 编辑:程序博客网 时间:2024/06/02 02:21
一 代码
td{ font-size:9pt;}.style2 {color: #FFFFFF}<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><link href="style.css" rel="stylesheet"><title>应用mysql_fetch_row()函数从数组结果集中获取信息</title></head><body><table width="609" height="134" border="1" cellpadding="0" cellspacing="0" bgcolor="#9E7DB4" align="center"> <form name="myform" method="post" action=""> <tr> <td width="605" height="51" bgcolor="#CC99FF"><div align="center">请输入图书名称 <input name="txt_book" type="text" id="txt_book" size="25" > <input type="submit" name="Submit" value="查询"> </div></td> </tr></form> <tr valign="top" bgcolor="#FFFFFF"> <td height="81"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="79" align="center" valign="top"> <br> <table width="572" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#625D59"> <tr align="center" bgcolor="#CC99FF"> <td width="46" height="20">编号</td> <td width="167">图书名称</td> <td width="90">出版时间</td> <td width="70">图书定价</td> <td width="78">作者</td> <td width="114">出版社</td> </tr> <?php$link=mysql_connect("localhost","root","root") or die("数据库连接失败".mysql_error());mysql_select_db("db_database13",$link);mysql_query("set names gb2312");$sql=mysql_query("select * from tb_book");$row=mysql_fetch_row($sql);if ($_POST[Submit]=="查询"){$txt_book=$_POST[txt_book];$sql=mysql_query("select * from tb_book where bookname like '%".trim($txt_book)."%'"); //如果选择的条件为"like",则进行模糊查询$row=mysql_fetch_row($sql);}if($row==false){ //如果检索的信息不存在,则输出相应的提示信息 echo "<div align='center' style='color:#FF0000; font-size:12px'>对不起,您检索的图书信息不存在!</div>";}do{ ?> <tr align="left" bgcolor="#FFFFFF"> <td height="20" align="center"><?php echo $row[0]; ?></td> <td > <?php echo $row[1]; ?></td> <td align="center"><?php echo $row[2]; ?></td> <td align="center"><?php echo $row[3]; ?></td> <td align="center"> <?php echo $row[4]; ?></td> <td> <?php echo $row[5]; ?></td> </tr> <?php}while($row=mysql_fetch_row($sql));?> </table></td> </tr> </table> <br></td> </tr> </table></body></html>
二 运行结果
阅读全文
0 0
- PHP+MySQL 利用mysql_fetch_row模糊查询图书信息
- PHP+MySQL 利用mysql_fetch_object模糊查询图书信息
- PHP+MySQL 利用mysql_num_rows模糊查询图书信息
- PHP+MySQL模糊查询员工信息
- PHP - mysql mysql_fetch_assoc mysql_fetch_row mysql_fetch_array mysql_fetch_object 区别
- autocomplete+PHP+MYSQL的实现模糊查询
- autocomplete+PHP+MYSQL的实现模糊查询
- php 简单内容查询代码 利用sql like模糊查询
- jsp查询所有图书信息
- php 数组模糊查询
- php模糊查询
- php模糊查询知识点
- PHP模糊查询
- PHP的模糊查询
- 模糊查询.php
- php 模糊查询
- php 数组模糊查询
- PHP 抓取豆瓣图书信息
- PHP+MYSQL 执行SQL语句
- 驱动开发中的小技巧记录
- PHP+MySQL 利用mysql_fetch_object模糊查询图书信息
- Oracle中的时间函数用法(to_date、to_char) (总结)
- org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /
- PHP+MySQL 利用mysql_fetch_row模糊查询图书信息
- JAVA设计模式之静态代理模式
- 序列化和反序列化的简单理解
- 查看 SELinux状态及关闭SELinux
- PHP+MySQL模糊查询员工信息
- PHP+MySQL 利用mysql_num_rows模糊查询图书信息
- NDK
- ADODB在PHP环境中的下载和安装
- 树莓派