我在我的网站上的搜索有问题 我不明白为什么它会给我这个错误
这是我的表单代码
<form action="index.php?cat=search_results&learn_id=1" method="post">
<div id="topSearchBodyStyle">
<input type="text" name="search" class="topSearchTextBackground" />
</div>
<div id="topSearchButtonStyle">
<input type="submit" name="submit" class="topSearchButtonBackground" value="" />
</div>
</form>
这是有php代码的页面
<?php
$getSearch = $_POST['search'];
trim($getSearch);
if(!get_magic_quotes_gpc()) {
$getSearch = addslashes($getSearch);
}
$connectToDb = "select * from tutorials where tutorial_title like '%.$getSearch.%'";
$searchResults = $db->query($connectToDb) or die($db->error);
if ($searchResults){
$numResultas = $searchResults ->num_rows;
echo "<p>Found : " . $numResultas . "</p>";
while($row = mysqli_fetch_array($searchResults)) {
echo $row['tutorial_title'];
}
}else{
echo "cant connect";
}
?>
知道为什么它给我关于“未定义索引:搜索”的注释以及为什么结果为“0”