0
Good afternoon to all,
I’m developing a code for searching keywords in the database. So far, ok! However, I am skating while trying to open the file referring to the result I found.
This is the keyword search code:
<?php
// Include conexão com o bd.
include 'conexaoBD/conexao.php';
include 'teste.php';
$btn = $_POST['btn'];
$p_chave = $_POST['palavra'];
if(isset($btn)){
$busca = $p_chave;
if($busca == null or $busca == " "){
echo '<center><b>Digite a palavra-chave para pesquisar!</b></center>';
} else {
$busca_div = explode(' ',$busca);
$quant = count($busca_div);
$exibe_id = array("");
for($i=0; $i<$quant; $i++){
$pesquisa = $busca_div[$i];
$_sql = "SELECT * FROM conteudo_dcm WHERE DCM_conteudo LIKE '%$pesquisa%';";
$sql = mysqli_query($conn,$_sql);
$quant_cmps = mysqli_num_rows($sql);
if($quant_cmps == 0){
echo '<center><b>Nenhum resultado obtido!</b></center>';
} else {
while($linha = mysqli_fetch_array($sql)){
$id = $linha['DCM_id'];
$nome = $linha['DCM_nome'];
$conteudo = $linha['DCM_conteudo'];
$_href = $_folder.$_DS.$nome; // Variável definida no arquivo "teste.php"
if(!array_search($id,$exibe_id)){
echo '<a href="<?php $_href; ?>">'.$nome.'</a>'."<br><br>".
substr($conteudo, 0, 600)."<b> ...</b>".
"<br>---------------------<br>";
array_push($exibe_id,$id);
}
}
}
}
}
}
?>
My question is mainly on this part of the code (like mounting the url refente to the file I saved on the server).
echo '<a href="<?php $_href; ?>">'.$nome.'</a>'."<br><br>".
substr($conteudo, 0, 600)."<b> ...</b>".
"<br>---------------------<br>";
I’m guessing that your variable
$folder
is filled with the directory within the operating system where you write the files, is that right? If this is the case you have to translate this path to the route that leads to the file by entering http. If you can put the section that creates this variable I can try to help more.– Diego Martins
Yes @Diegomartins, the $Folder variable is the directory where the Arq. are stored. Follow the passage that creates this variable: "$_DS = DIRECTORY_SEPARATOR; $_Folder = dirname(DIR).$_DS.'03-OCR-Pdflib'. $_DS.'arqs_Teste'; "
– user145547