Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Jacob Mahto
Added: Mar 26, 2018 6:52 PM
Views: 26
Tags: no tags
  1. <?php
  2. if(isset($_POST['submit'])){
  3.     $search = $_POST['search'];
  4.     $query = "SELECT * FROM posts WHERE post_tags LIKE '%$search%' ";
  5.     $search_query = mysqli_query($connection,$query);
  6.     if(!$search_query){
  7.         die("QUERY FAILED".mysqli_error($connection));
  8.     }
  9.     else{
  10.         echo "<script>alert('found');</script>";
  11.     }
  12.     $count = mysqli_num_rows($search_query);
  13.     if($count == 0){
  14.         echo "<h1>No Result</h1>";
  15.     }
  16.     else {
  17.         echo "Some result";
  18.     }
  19. }
  20. ?>