Jump to content

drakor

New Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by drakor

  1. In my database I got table with keywords row.Keywords are separated by the commas(dog, black, German, white, dangerous).If I type single search term for example dog it will return result for dog however if i type two terms for example dangerous dog it returns 0 results.I want for my code to return results for multiple terms...Someone suggested explode the array of search words and do an OR condition in my query with the exploded array but I am a noob and don't know how to do it.Any help would be appreciated! My code is bellow. <?php if(isset($_POST['search'])){ $get_value = addslashes($_POST['search']); $search = mysqli_real_escape_string($con,"$get_value"); ?> <h2>Showing results for <?php echo $_POST['search'] ?></h2> <?php if($search==''){ echo "<center><b>Please write something in the search box!</b></center>"; exit(); } $result_query = "SELECT * FROM content WHERE keywords LIKE '%".$search."%'"; $run_result = mysqli_query($con,$result_query); // echo mysqli_num_rows($run_result); // exit; if(mysqli_num_rows($run_result)<1){ echo "<center>Sorry no matches found</center>"; exit(); } while($row_result=mysqli_fetch_array($run_result)) { $name=$row_result['name']; $keywords=$row_result['keywords']; $image=$row_result['image']; $link=$row_result['link']; ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.