Motor de busca php para um forum(PAP/Ajuda)

Bom dia estou a desenvolver um forum para a minha pap e já tenho algumas coisas feitas como categorias tópicos , criação de tópicos etc... mas gostava de fazer um motor de pesquisa para procurar para ajudar na procura de um certo tópico , eu aprendi nas aulas uma forma de fazer mas não sei como implementar neste código alguém me consegue ajudar ?

Codigo do forum onde mostro os topicos ;
<table border="1px;">
<tr>
<td width="400px;" style="text-align: center;">
Titulo
</td>
<td width="400px;" style="text-align: center;">
Criador
</td>
<td width="400px;" style="text-align: center;">
Visualizações
</td>
<td width="400px;" style="text-align: center;">
Respostas
</td>
<td width="400px;" style="text-align: center;">
Data
</td>


</tr>
<div class="text">
<?php

include("conexao.php");
$pesquisa = $_GET["pesquisa"];
$check = mysqli_query($ligaBD ,"SELECT * FROM topico WHERE idcat = '".$cid."' ORDER BY data DESC");

if(mysqli_num_rows($check)!=0){
while($row=mysqli_fetch_assoc($check)){

@$id = $row['idt'];
@$uti = $row['utilizador'];
@$idcat = $row['idcat'];
echo"<tr>";
echo"<td><a href='respostas.php?id=$id?idcat=$idcat'>".$row['titulo']."</a></td>";
echo"<td><a href='perfil2.php?uti=$uti'>".$row['utilizador']."</td>";
echo"<td>".$row['respostas']."</td>";
echo"<td>".$row['views']."</td>";
echo"<td>".$row['data']."</td>";
echo"</tr>";
}
}else{
echo "No topics found";
}
echo "</table>";

?>
Codigo do motor de pesquisa que aprendi nas aulas ;

<form action = "listar.php" method = "GET">
<table border = "0">
<tr> <td> <input type = "text" id = "pesquisa" name = "pesquisa" placeholder="Nome da Obra">
<td> <br> <input type = "submit" value = "Pesquisar"> <br><br>
</form>

<?php
include("validar.php");

echo "<h2> Listar candidatos </h2>";

include("conecao.php");

$pesquisa = $_GET["pesquisa"];

$pergunta = "SELECT * FROM partituras WHERE titulo like '%$pesquisa%'";

$resultado = mysqli_query($ligaBD, $pergunta);

$num_linhas = mysqli_num_rows($resultado);
if($num_linhas == 0){
echo "Não existem registos para listar <br>";
}

echo "Número total de registos encontrados: ".$num_linhas."<br><br>";

echo "<table border = 1>";
echo "<tr>";
echo "<th>idp</th>";
echo "<th>titulo</th>";
echo "<th>autor</th>";
echo "</th>";

for ($i = 0; $i < $num_linhas; $i++){
$dados = mysqli_fetch_array($resultado);

if(!$dados){
echo "<br> Eroo: Leitura dos registos devolvidos pela ação sobre a BD.";
exit;
}
echo '<tr>';
echo '<td>'.$dados["idp"]."</td>";
echo '<td>'.$dados["titulo"]."</td>";
echo '<td>'.$dados["autor"]."</td>";
echo '</tr>';
}

echo "</table>";
echo "<a href = main.php class = cancelbtn > <br> Voltar </a>";
?>
 
codigo onde mostro os topicos
Código:
<table border="1px;">
<tr>
<td width="400px;" style="text-align: center;">
Titulo
</td>
<td width="400px;" style="text-align: center;">
Criador
</td>
<td width="400px;" style="text-align: center;">
Visualizações
</td>
<td width="400px;" style="text-align: center;">
Respostas
</td>
<td width="400px;" style="text-align: center;">
Data
</td>


</tr>
<div class="text">
<?php

include("conexao.php");
$pesquisa = $_GET["pesquisa"];
$check = mysqli_query($ligaBD ,"SELECT * FROM topico WHERE idcat = '".$cid."' ORDER BY data DESC");

if(mysqli_num_rows($check)!=0){
while($row=mysqli_fetch_assoc($check)){

@$id = $row['idt'];
@$uti = $row['utilizador'];
@$idcat = $row['idcat'];
echo"<tr>";
echo"<td><a href='respostas.php?id=$id?idcat=$idcat'>".$row['titulo']."</a></td>";
echo"<td><a href='perfil2.php?uti=$uti'>".$row['utilizador']."</td>";
echo"<td>".$row['respostas']."</td>";
echo"<td>".$row['views']."</td>";
echo"<td>".$row['data']."</td>";
echo"</tr>";
}
}else{
echo "No topics found";
}
echo "</table>";

?>
motor de pesquisa feito nas aulas
Código:
<form action = "listar.php" method = "GET">
<table border = "0">
<tr> <td> <input type = "text" id = "pesquisa" name = "pesquisa" placeholder="Nome da Obra">
<td> <br> <input type = "submit" value = "Pesquisar"> <br><br>
</form>

<?php
include("validar.php");

echo "<h2> Listar candidatos </h2>";

include("conecao.php");

$pesquisa = $_GET["pesquisa"];

$pergunta = "SELECT * FROM partituras WHERE titulo like '%$pesquisa%'";

$resultado = mysqli_query($ligaBD, $pergunta);

$num_linhas = mysqli_num_rows($resultado);
if($num_linhas == 0){
echo "Não existem registos para listar <br>";
}

echo "Número total de registos encontrados: ".$num_linhas."<br><br>";

echo "<table border = 1>";
echo "<tr>";
echo "<th>idp</th>";
echo "<th>titulo</th>";
echo "<th>autor</th>";
echo "</th>";

for ($i = 0; $i < $num_linhas; $i++){
$dados = mysqli_fetch_array($resultado);

if(!$dados){
echo "<br> Eroo: Leitura dos registos devolvidos pela ação sobre a BD.";
exit;
}
echo '<tr>';
echo '<td>'.$dados["idp"]."</td>";
echo '<td>'.$dados["titulo"]."</td>";
echo '<td>'.$dados["autor"]."</td>";
echo '</tr>';
}

echo "</table>";
echo "<a href = main.php class = cancelbtn > <br> Voltar </a>";
?>
 
Back
Topo