PHP+MySQL 利用mysql_num_rows模糊查询图书信息
2017-11-22 10:41
585 查看
一 代码
二 运行结果
大小: 6.6 KB
查看图片附件
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_num_rows()函数获取查询结果集中的记录数</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="right" 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"); $info=mysql_fetch_object($sql); if ($_POST[Submit]=="查询"){ $txt_book=$_POST[txt_book]; $sql=mysql_query("select * from tb_book where bookname like '%".trim($txt_book)."%'"); //如果选择的条件为"like",则进行模糊查询 $info=mysql_fetch_object($sql); } if($info==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 $info->id; ?></td> <td > <?php echo $info->bookname; ?></td> <td align="center"><?php echo $info->issuDate; ?></td> <td align="center"><?php echo $info->price; ?></td> <td align="center"> <?php echo $info->maker; ?></td> <td> <?php echo $info->publisher; ?></td> </tr> <?php }while($info=mysql_fetch_object($sql)); ?> </table> <br> 找到相关记录 <?php $nums=mysql_num_rows($sql);echo $nums;?> 条 </td> </tr> </table> <br></td> </tr> </table> </body> </html>
二 运行结果
大小: 6.6 KB
查看图片附件
相关文章推荐
- PHP+MySQL使用mysql_num_rows实现模糊查询图书信息功能
- PHP+MySQL 利用mysql_fetch_object模糊查询图书信息
- PHP+MySQL 利用mysql_fetch_row模糊查询图书信息
- PHP+MySQL实现模糊查询员工信息功能示例
- PHP+MySQL模糊查询员工信息
- 利用cookie存放模糊查询的信息
- PHP,Mysql-根据一个给定经纬度的点,进行附近地点查询–合理利用算法,效率提高2125倍
- 【分享】利用豆瓣API根据ISBN查询图书信息
- PHP MYSQL实现登陆和模糊查询两大功能
- php的mysql模糊查询,可以允许空值(空值则查询全部)
- SSH框架利用注解方式实现根据多条件动态分页查询图书信息(传对象)
- php查询mysql表中所有字段详细信息
- 应用mysql_num_rows()函数获取查询结果集中的记录数
- PHP,Mysql-根据一个给定经纬度的点,进行附近地点查询–合理利用算法
- php用mysql_num_rows判断mysql_query结果集行数
- PHP,Mysql-根据一个给定经纬度的点,进行附近地点查询–合理利用算法,效率提高2125倍
- PHP MYSQL登陆和模糊查询
- 【个人学习之路】PHP和MySQL实现上传图书信息
- php中mysql_num_rows与count(*)的效率对
- autocomplete+PHP+MYSQL的实现模糊查询