以下是我的 search.php 代码:
<?php
if(isset($_POST['action']) && $_POST['action'] == "Search Question")
{
$search = mysql_real_escape_string(trim(htmlspecialchars($_POST['search'])));
$err = array();
if(isset($search))
{
if(empty($search))
$err[] = "Please write your question name";
elseif(is_numeric($search))
$err[] = "Wrong values entered";
}
if(!empty($err))
{
foreach($err as $er)
{
echo "<font color=red>$er<br/></font>";
}
}
else
{
$search_sql = mysql_query("SELECT * FROM questions WHERE q_name LIKE '%$search%'");
//$search_sql = mysql_query("SELECT * FROM questions WHERE MATCH(q_name, answer) AGAINST '$search' ");
$numserach = mysql_num_rows($search_sql);
if($numserach == 1)
{
echo "<font color='green'><strong>$numserach Question found</strong></font><br/>";
while($result = mysql_fetch_array($search_sql))
{
$subid = $result['sub_id'];
$id = $result['id'];
$qquestionsname = $result['q_name'];
////////////////////////////////////////////////// SEARCH SHOW START HERE ///////////////////////
//include("toppagi.php");
$questions = $result['q_name'];
echo "<a href='answerdetails.php?id=$id&subid=$subid&questionname=$qquestionsname'>$questions</a><br/>";
//include("bottompagi.php");
////////////////////////////////////////////////// SEARCH SHOW END HERE ///////////////////////
}
}
else
{
echo "<font color=red>No Result Found</font>";
}
}
}
?>
在我的数据库中,我正在尝试搜索存储我所有问题名称的“q_name”文件。像.. 会计、书籍、O 级、测试 o 级等。
好吧,但是如果我搜索ac OR te之类的东西,那么它不会显示任何结果。我需要如果我搜索ac或te或其他东西,那么它会显示一些结果..
提前致谢:)