【发布时间】:2016-02-17 10:22:45
【问题描述】:
在我的数据库上做一个简单的 PHP/SQL 搜索栏,结果没有出现。搜索栏出现,我输入的任何内容都没有出现在 URL 中。代码如下。我正在通过不同的文件连接到数据库。
Index.php
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<center>
<form action="search.php" method="post">
<input type="text" name="search" autocomplete="off">
<input type="submit" value="search">
</form>
</center>
</body>
</html>
search.php
<?php
$search = $_GET['search'];
require 'constants.php';
?>
<?php
$query = "SELECT Name, Zip, Address, Type FROM parks WHERE Zip = '%{$search}%'";
$result = mysqli_query($db_connection,$query);
while ($row = mysqli_fetch_array($result))
{
// loop through output one row at a time
$name = $row["Name"];
$zip = $row["Zip"];
$address = $row["Address";
$type = $row["Type"];
echo $name . $zip . $address . $type;
}
?>
【问题讨论】: