我一直在尝试为我的数据库制作一个搜索引擎,但没有成功
我想做的是在多个列中搜索数据库,
我尝试过$select = "SELECT * FROM letter_cast WHERE name LIKE '%".$_GET['content']."%' AND title LIKE '%".$_GET['content']。 “%'”;
但运气不好,我猜整个脚本有一些不同,这是脚本(我从 here 下载的)
// You can do anything with the data. Just think of the possibilities!
include('conn.php');
$strlen = strlen($_GET['content']);
$display_count = $_GET['count'];
$select = "SELECT * FROM letter_cast WHERE name LIKE '%".$_GET['content']."%' AND title LIKE '%".$_GET['content']."%'";
$res = mysql_query($select);
$rec_count = mysql_num_rows($res);
if($display_count)
{
echo "There are <font color='red' size='3'>".$rec_count."</font> matching records found.Click Search to view result.";
}
最佳答案
除了您的脚本完全不安全之外,AND 逻辑还限制您的查询,如果您考虑到某些列,则需要使用 OR。
关于php - 如何在 php 和 ajax 中搜索列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6394137/