我正在建立一个工作库存系统,我已经有一个搜索系统来搜索数据库。但是当我搜索名称中包含任何空格的项目时,它没有找到任何结果。这是我的脚本,任何帮助将不胜感激。
<?php
// we connect to our Database
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("inventory") or die(mysql_error());
$find = $_POST['find'];
echo "<h2>Search Results:</h2><p>";
//If they did not enter a search term we give them an error
if ($find == "")
{
echo "<p>You forgot to enter a search term!";
exit;
}
// We perform a bit of filtering
$find = strtoupper($find);
$find = strip_tags($find);
$find = trim ($find);
//Now we search for our search term, in the field the user specified
$data = mysql_query("SELECT * FROM parts WHERE vendor LIKE'%$find%' OR category
LIKE'%$find%' OR prtid LIKE'%$find%' OR description LIKE '%$find%'");
if (!$data) { // add this check.
die('Invalid query: ' . mysql_error());
}