Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit dd80f21

Browse files
添加数据库函数应用
1 parent 8509697 commit dd80f21

File tree

2 files changed

+61
-53
lines changed

2 files changed

+61
-53
lines changed

‎.idea/workspace.xml‎

Lines changed: 45 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎php-mysql/book_search/index.php‎

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@
2929
$info = mysqli_fetch_array($sql);//获取查询结果,返回值为数组
3030
if($_POST['submit'] == '查询'){ //判断按钮 submit 的值是否为查询
3131
$txt_book = trim($_POST['txt_book']); //获取文本框提交的值
32-
echo "<p>您输入的关键词为:$txt_book";
32+
echo "<p>您输入的关键词为:$txt_book<br>";
3333
$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>';
3436
$info = mysqli_fetch_array($sql); //获取查询结果
37+
3538
if (!$sql) {
3639
printf("Error: %s\n", mysqli_error($conn));
3740
exit();
@@ -45,20 +48,20 @@
4548
$table = <<<HTML
4649
<table border="0">
4750
<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>
5457
</tr>
5558
<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>
6265
</tr>
6366
</table>
6467
HTML;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /