php:<p>
Search the employee database:<br />
<form action="<?php htmlspecialchars($_SERVER['PHP_SELF']);?>" method="post">
Keyword:<br />
<input type="text" name="lastname" size="20" maxlength="40" value=""/><br />
<input type="submit" name="Submit" value="Search!"/>
</form>
</p>
<?php
if (isset($_POST['Submit'])) {
if (isset($_POST['lastname'])) {
$mysqldb = new mysqli('localhost', 'QQAA2233', '3322QQAA', 'corporate');
$keyword = mysqli_real_escape_string($mysqldb, $_POST['lastname']);
$result = mysqli_query($mysqldb, "SELECT first_name, email FROM employees WHERE MATCH(last_name) AGAINST('$keyword')");
if (mysqli_num_rows($result) > 0) {
while (($row = mysqli_fetch_object($result)) == true)
echo "$row->first_name ($row->email)<br />";
}
else
echo 'No results found.';
}
}
?>
数据库corporate:表employees:
| id | employee_id | first_name | last_name | email | phone |salary |
+----+-------------+------------+-----------+---------------------+------------+--------+
| 1 | 1 | Bob | Connors | [email protected] | 2125559945 |100.00 |
| 2 | 2 | Jason | Gilmore | [email protected] | 2125551212 |200.00 |
| 3 | 3 | Matt | Wade | [email protected] | 2125559999 |300.00 |
| 4 | | Mike | Ailmore | [email protected] | |0.00 |
其中last_name中有两个有相同ilmore,Gilmore与Ailmore。但我在PHP中输入ilmore为什么不能显示Jason与Mike的列?提示
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in D:\xampp\htdocs\Project\newfile3.php on line 20
No results found.
Search the employee database:<br />
<form action="<?php htmlspecialchars($_SERVER['PHP_SELF']);?>" method="post">
Keyword:<br />
<input type="text" name="lastname" size="20" maxlength="40" value=""/><br />
<input type="submit" name="Submit" value="Search!"/>
</form>
</p>
<?php
if (isset($_POST['Submit'])) {
if (isset($_POST['lastname'])) {
$mysqldb = new mysqli('localhost', 'QQAA2233', '3322QQAA', 'corporate');
$keyword = mysqli_real_escape_string($mysqldb, $_POST['lastname']);
$result = mysqli_query($mysqldb, "SELECT first_name, email FROM employees WHERE MATCH(last_name) AGAINST('$keyword')");
if (mysqli_num_rows($result) > 0) {
while (($row = mysqli_fetch_object($result)) == true)
echo "$row->first_name ($row->email)<br />";
}
else
echo 'No results found.';
}
}
?>
数据库corporate:表employees:
| id | employee_id | first_name | last_name | email | phone |salary |
+----+-------------+------------+-----------+---------------------+------------+--------+
| 1 | 1 | Bob | Connors | [email protected] | 2125559945 |100.00 |
| 2 | 2 | Jason | Gilmore | [email protected] | 2125551212 |200.00 |
| 3 | 3 | Matt | Wade | [email protected] | 2125559999 |300.00 |
| 4 | | Mike | Ailmore | [email protected] | |0.00 |
其中last_name中有两个有相同ilmore,Gilmore与Ailmore。但我在PHP中输入ilmore为什么不能显示Jason与Mike的列?提示
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in D:\xampp\htdocs\Project\newfile3.php on line 20
No results found.
解决方案 »
- 这个webservice地址怎么调用?
- win7系统如何配置smtp服务器?
- virtualbox/vmware 安装了ubuntu,如何设置网络连接,使用xampp的ftp
- 谁帮我看看哪里错了,Parse error: parse error, unexpected $end ,谢谢啊!!!
- 用php session统计用户访问次数
- php的escape函数问题,错误
- linux ajax php .net最新培训视频
- 完全免费的帝国备份王1.3版本下载[2005-06]
- 在线焦急等待!如何实现在一个web页中对一个数据库(mysql环境下)中的多个表格的查询呢?具体情况如下:
- 请教SMARTY 发帖后clearCache 文章列表的逻辑
- 练习php文件下载:提示打不开图片文件,因为此文件可能已经损坏,或者过大
- PHP新手请教:getimagesize不能获取远程图片信息!??急
看看都是什么错
我已经在last_name上建立了全文索引了,不过始终还是No results found.我在mysql中select match(last_name) against('ilmore') from employees;但显示
+------------------------------------+
| match(last_name) against('ilmore') |
+------------------------------------+
| 0 |
| 0 |
| 0 |
| 0 |
+------------------------------------+
全部为0,是不是我的用法错误呢
+-------------+----------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+----------------------+------+-----+---------+----------------+
| id | smallint(5) unsigned | NO | PRI | NULL | auto_increment |
| employee_id | char(8) | NO | | NULL | |
| first_name | varchar(25) | NO | | NULL | |
| last_name | varchar(35) | NO | MUL | NULL | |
| email | varchar(55) | NO | | NULL | |
| phone | char(10) | NO | | NULL | |
| salary | decimal(8,2) | NO | | NULL | |
+-------------+----------------------+------+-----+---------+----------------+
另外我添加了索引fulltext(last_name)
mysql> show table status like '%employees%'\G;
*************************** 1. row ***************************
Name: employees
Engine: MyISAM
Version: 10
Row_format: Dynamic
Rows: 4
Avg_row_length: 52
Data_length: 208
Max_data_length: 281474976710655
Index_length: 3072
Data_free: 0
Auto_increment: 5
Create_time: 2012-10-26 08:48:19
Update_time: 2012-10-26 08:48:19
Check_time: NULL
Collation: latin1_swedish_ci
Checksum: NULL
Create_options:
Comment:
1 row in set (0.00 sec)
不是ALTER TABLE employees ADD FULLTEXT(last_name);这样子的吗?