|
29 | 29 | $info = mysqli_fetch_array($sql);//获取查询结果,返回值为数组
|
30 | 30 | if($_POST['submit'] == '查询'){ //判断按钮 submit 的值是否为查询
|
31 | 31 | $txt_book = trim($_POST['txt_book']); //获取文本框提交的值
|
32 | | - echo "<p>您输入的关键词为:$txt_book"; |
| 32 | + echo "<p>您输入的关键词为:$txt_book<br>"; |
33 | 33 | $sql = mysqli_query($conn," select * from tb_book where bookname LIKE '%".$txt_book."%'");//执行模糊查询
|
| 34 | + $num = mysqli_num_rows($sql);//使用mysqli_num_rows()获取查询结果集中的记录数 |
| 35 | + echo @'Rows:'.$num.'<br>'; |
34 | 36 | $info = mysqli_fetch_array($sql); //获取查询结果
|
| 37 | + |
35 | 38 | if (!$sql) {
|
36 | 39 | printf("Error: %s\n", mysqli_error($conn));
|
37 | 40 | exit();
|
|
45 | 48 | $table = <<<HTML
|
46 | 49 | <table border="0">
|
47 | 50 | <tr align="left" bgcolor="#f5f5f5" >
|
48 | | -<td height="20" align="center">编号</td> |
49 | | -<td height="20" align="center">图书名称</td> |
50 | | -<td height="20" align="center">出版时间</td> |
51 | | -<td height="20" align="center">图书定价</td> |
52 | | -<td height="20" align="center">作者</td> |
53 | | -<td height="20" align="center">出版社</td> |
| 51 | +<td height="20" width="205" align="center">编号</td> |
| 52 | +<td height="20" width="205" align="center">图书名称</td> |
| 53 | +<td height="20" width="205" align="center">出版时间</td> |
| 54 | +<td height="20" align="center" width="205" >图书定价</td> |
| 55 | +<td height="20" align="center" width="205" >作者</td> |
| 56 | +<td height="20" align="center" width="205" >出版社</td> |
54 | 57 | </tr>
|
55 | 58 | <tr align="left" bgcolor="#fff">
|
56 | | -<td height="20" align="center">$info[id]</td> |
57 | | -<td height="20" align="center">$info[bookname]</td> |
58 | | -<td height="20" align="center">$info[issu_date]</td> |
59 | | -<td height="20" align="center">$info[price]</td> |
60 | | -<td height="20" align="center">$info[maker]</td> |
61 | | -<td height="20" align="center">$info[publisher]</td> |
| 59 | +<td height="20" align="center" width="205" >$info[id]</td> |
| 60 | +<td height="20" align="center" width="205" >$info[bookname]</td> |
| 61 | +<td height="20" align="center" width="205" >$info[issu_date]</td> |
| 62 | +<td height="20" align="center" width="205" >$info[price]</td> |
| 63 | +<td height="20" align="center" width="205" >$info[maker]</td> |
| 64 | +<td height="20" align="center" width="205" >$info[publisher]</td> |
62 | 65 | </tr>
|
63 | 66 | </table>
|
64 | 67 | HTML;
|
|
0 commit comments