search system that searches in two different tables!

0

I created a search engine.

$search = Fnc::_GET('q');

   if($search != null){

      $results = Select::baseData("users.name,users.user,posts.title", "users INNER JOIN posts ON users.user = posts.user", "WHERE users.name LIKE :NAME OR users.user LIKE :USER AND posts.title LIKE :TITLE", [
          'NAME' => "%{$search}%",
          'USER' => "%{$search}%",
          'TITLE' => "%{$search}%"
      ]); 

      if(count($results) > 0){
         foreach ($results as $value) {
            echo "Nome: {$value->name}";
            echo "<hr>";
            echo "Titulo: {$value->title}";
            echo "<hr>";
         }
      }else{
        echo "Não encontramos nada!";
      }
   }

But it only returns the data of a user, I would like it to return the data of the two tables in the same search.

    
asked by anonymous 19.05.2018 / 19:04

0 answers