【发布时间】:2019-07-09 14:44:35
【问题描述】:
我的分页与表格一起工作,但我想要一个搜索引擎,如何将搜索引擎添加到其中?我有一个简单的搜索表单,但不知道如何集成。
<html>
<head>
<title>Search</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
</head>
<form method="get" action="index.php">
<label>Search: <input type="text" name="query"/>
<input type="submit" name = "search" value="search" />
</form>
<?php
include('db.php');
if (isset($_GET['page_no']) && $_GET['page_no']!="") {
$page_no = $_GET['page_no'];
} else {
$page_no = 1;
}
$total_records_per_page = 10;
$offset = ($page_no-1) * $total_records_per_page;
$previous_page = $page_no - 1;
$next_page = $page_no + 1;
$adjacents = "2";
$result_count = mysqli_query($con,"SELECT COUNT(*) As total_records FROM `cases`");
$total_records = mysqli_fetch_array($result_count);
$total_records = $total_records['total_records'];
$total_no_of_pages = ceil($total_records / $total_records_per_page);
$second_last = $total_no_of_pages - 1; // total page minus 1
$result = mysqli_query($con,"SELECT * FROM `cases` LIMIT $offset, $total_records_per_page");
while($row = mysqli_fetch_array($result)){
echo "<tr>
<td>".$row['name']."</td>
<td>".$row['email']."</td>
<td>".$row['phone']."</td>
<td>".$row['case']."</td>
</tr>";
}
mysqli_close($con);
?>
</tbody>
</table>
【问题讨论】:
-
查看 SQL Where 命令
标签: php html css mysqli search-engine