我正在创建一个搜索框,它只能通过部分写入值来工作,但我不知道怎么做?
这是代码:
$sql = "SELECT id, name, someElse FROM My.basic_info WHERE id = '.$searched.' LIKE '%" .$searched."%' ";
$result = mysql_query($sql) or die ("Query to POST data from try failed: ".mysql_error());
if ($rows=mysql_fetch_assoc($result)) {
echo $rows['id'];
echo "<br>";
echo $rows['name'];
echo "<br>";
echo $rows['someElse'];
echo "<br>";
} else {
echo "What you've searched for cannot be found or isn't the correct checkbox";
echo "<br>";
}
为什么不起作用?在此先感谢!!
答案 0 :(得分:0)
首先,尝试删除sql的字符串中的变量:
$sql = "SELECT id, name, someElse FROM My.basic_info WHERE id LIKE '%" .$searched."%' ";