Boas malta , tenho esse codigo ai de um motor de busca dinamico tipo google. ta funcionando tudo direitinho
mas agora keria por a palavra procurada no momento tipo em <b> ou cor diferente, alguém sabe algum jeito de fazer isso?
obrigado
<?php
include_once("data/init.php");
$tab = "sala";
$q = $_GET["q"];
$result_set = mysql_query("SELECT * FROM `$tab` WHERE nome LIKE '%$q%'");
$sql = mysql_fetch_assoc($result_set);
$a = mysql_num_rows($sql);
//com registo
while ($sql)
{
$c[] = $sql["local"];
$b[] = $sql["id"];
$a[] = $sql["nome"];
//////
$sql = mysql_fetch_assoc($result_set);
}
///////////////////////////////////////////////////
//lookup all hints from array if length of q>0
if (strlen($q) > 0)
{
$hint="";
for($i=0; $i<count($a); $i++)
{
if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q))))
{
if ($hint=="")
{
$hint = "<a href=produto.php?id=".$b[$i].">$a[$i]</a>";
}
else
{
$hint=$hint." , "."<a href=produto.php?id=".$b[$i].">$a[$i]</a>";
}
}
}
}
// Set output to "no suggestion" if no hint were found
// or to the correct values
if ($hint == "")
{
$response="<font color='#888888'>Sem resultados</font>";
}
else
{
$response=$hint;
}
//output the response
echo $response;
?>
Pergunta
m3io
Boas malta , tenho esse codigo ai de um motor de busca dinamico tipo google. ta funcionando tudo direitinho
mas agora keria por a palavra procurada no momento tipo em <b> ou cor diferente, alguém sabe algum jeito de fazer isso?
obrigado
<?php include_once("data/init.php"); $tab = "sala"; $q = $_GET["q"]; $result_set = mysql_query("SELECT * FROM `$tab` WHERE nome LIKE '%$q%'"); $sql = mysql_fetch_assoc($result_set); $a = mysql_num_rows($sql); //com registo while ($sql) { $c[] = $sql["local"]; $b[] = $sql["id"]; $a[] = $sql["nome"]; ////// $sql = mysql_fetch_assoc($result_set); } /////////////////////////////////////////////////// //lookup all hints from array if length of q>0 if (strlen($q) > 0) { $hint=""; for($i=0; $i<count($a); $i++) { if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q)))) { if ($hint=="") { $hint = "<a href=produto.php?id=".$b[$i].">$a[$i]</a>"; } else { $hint=$hint." , "."<a href=produto.php?id=".$b[$i].">$a[$i]</a>"; } } } } // Set output to "no suggestion" if no hint were found // or to the correct values if ($hint == "") { $response="<font color='#888888'>Sem resultados</font>"; } else { $response=$hint; } //output the response echo $response; ?>Link para o comentário
Compartilhar em outros sites
2 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.