I have made this page to search my site but here in my MySQLi I am looking in the column title so if the user didn't find what he looking for I will include a advanced search which will look into the content of the tutorials so the user can get any results.
this the complete code of my page.
how to adjust my code to meet my requirements.
Thanks
regards
this the complete code of my page.
Code:
<?php
if (isset($_POST['search'])){
$getSearch = clean_text($_POST['search']);
$connectToDb = "select * from tutorials where tutorial_title like '%".$getSearch."%' and active=1";
$searchResults = $db->query($connectToDb) or die($db->error);
$numResultas = $searchResults ->num_rows;
echo "<p class='counter_search'>Found : " . $numResultas . "</p>";
switch ($numResultas) {
case 0:
include "searchPageAdvanced.php";
break;
case $numResultas >= 1:
while($row = mysqli_fetch_array($searchResults)) {
echo "<a class='counter_linkHeader' href='index.php?cat=tutorials_view&learn_id=5&tutorial_id=".$row['tutorial_id']."'>".$row['tutorial_title']."</a>";
echo "<p class='counter_description'>";
$your_desired_width=200;
$description=$row['content'];
if (strlen($description) > $your_desired_width) {$description = wordwrap($description, $your_desired_width); $description = substr($description, 0, strpos($description, "\n"))." ..."; } echo $description;
echo"</p>";
}
break;
}
}else{
?>
<p> </p>
<table width="875" border="0">
<tr>
<td align="center" valign="middle"><img src="images/searchError.jpg" width="223" height="147" alt="search error" /></td>
</tr>
<tr>
<td align="center" valign="middle">Sorry you came here by mistake <br />
please use the search box to get results</td>
</tr>
</table>
<p> </p>
<?php
}
?>
Thanks
regards
Comment