<分区>
我创建了搜索引擎,因此当有人在搜索框中输入内容时,它会从我的数据库中获取数据并以图像形式显示结果。
一切正常,但如果我在数据库中有名称为“Lamborghini”的数据,当有人在搜索框中输入“lambo”或“Lamborghini”时,它工作正常并显示结果,但当他输入“Lamborghini car”时它没有显示任何结果。
这是我的 PHP 代码:
<html>
<link href="css/imgpages.css" rel="stylesheet" type="text/css">
<head>
<title>Search the Database</title>
</head>
<body>
<form action="" method="post">
Search: <input type="text" name="term" /><br />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
<?php
include("connection.php");
$term = $_POST['term'];
$query = mysql_query("select * from save_data where Title like '%$term%'");
while($row = mysql_fetch_array($query)) {
$post_id = $row['ID'];
$title = $row['Title'];
$image = $row['Name'];
?>
<div id="body">
<a href="pictures.php?title=<?php echo $title; ?>">
<div id="title"><?php echo $title; ?></div></a>
<a href="pictures.php?title=<?php echo $title; ?>">
<img src='uploads/<?php echo $image; ?>' width='140' height='140'></a>
</div>
<?php } ?>