


This article mainly introduces the use of PHP MySQL mysql_num_rows to realize the fuzzy query book information function, involving PHP's use of mysql's like query statement for fuzzy query and mysql_num_rows for structural statistics related operating skills, friends in need You can refer to the following
The example of this article describes how PHP MySQL uses mysql_num_rows to realize the fuzzy query book information function. Share it with everyone for your reference, the details are as follows:
1. Code
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="external nofollow" 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"><p align="center">请输入图书名称 <input name="txt_book" type="text" id="txt_book" size="25" > <input type="submit" name="Submit" value="查询"> </p></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 "<p align='center' style='color:#FF0000; font-size:12px'>对不起,您检索的图书信息不存在!</p>"; } 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>
2. Running results
Note: Use mysql_num_rows()
here to return the number of rows in the result set. This command is only valid for the SELECT statement. To get the rows affected by the INSERT, UPDATE or DELETE query number, you need to use <a href="http://www.php.cn/wiki/1162.html" target="_blank">mysql_affected_rows</a>()
.
Related recommendations:
##
The above is the detailed content of PHP+MySQL uses mysql_num_rows to implement fuzzy query book information function. For more information, please follow other related articles on the PHP Chinese website!

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于架构原理的相关内容,MySQL Server架构自顶向下大致可以分网络连接层、服务层、存储引擎层和系统文件层,下面一起来看一下,希望对大家有帮助。

在mysql中,可以利用char()和REPLACE()函数来替换换行符;REPLACE()函数可以用新字符串替换列中的换行符,而换行符可使用“char(13)”来表示,语法为“replace(字段名,char(13),'新字符串') ”。

方法:1、利用right函数,语法为“update 表名 set 指定字段 = right(指定字段, length(指定字段)-1)...”;2、利用substring函数,语法为“select substring(指定字段,2)..”。

mysql的msi与zip版本的区别:1、zip包含的安装程序是一种主动安装,而msi包含的是被installer所用的安装文件以提交请求的方式安装;2、zip是一种数据压缩和文档存储的文件格式,msi是微软格式的安装包。

转换方法:1、利用cast函数,语法“select * from 表名 order by cast(字段名 as SIGNED)”;2、利用“select * from 表名 order by CONVERT(字段名,SIGNED)”语句。

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于MySQL复制技术的相关问题,包括了异步复制、半同步复制等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了mysql高级篇的一些问题,包括了索引是什么、索引底层实现等等问题,下面一起来看一下,希望对大家有帮助。

在mysql中,可以利用REGEXP运算符判断数据是否是数字类型,语法为“String REGEXP '[^0-9.]'”;该运算符是正则表达式的缩写,若数据字符中含有数字时,返回的结果是true,反之返回的结果是false。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 English version
Recommended: Win version, supports code prompts!

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
