PHP mysql search multiple tables using a keyword

前端 未结 4 696
时光说笑
时光说笑 2020-11-28 04:01

I have three tables in my database which are:

messages
topics
comments

Each of these tables has two fields called \'content\' and \'title\'

4条回答
  •  囚心锁ツ
    2020-11-28 04:49

    Html Search form:

    Search.php:

    link, $fm->validation($_GET['search']));
        }
        else{
            header("Location:404.php");
        }
    ?>
    select($query);
        if ($post) {
            while ($result = $post->fetch_assoc()) {
                echo"Database data like, $result['title']";
            }
        }
        else{
            echo "result Not found";
        }
    

    include database.php in search.php

    class Database{
        public function select($query){
            $result = $this->link->query($query) or die($this->link->error.__LINE__);
            if($result->num_rows > 0){
                return $result;
            }
            else {
                return false;
            }
        }
    }
    $db = new Database();
    

提交回复
热议问题