Ver Mensaje Individual
  #7 (permalink)  
Antiguo 12/06/2009, 15:24
catalin
 
Fecha de Ingreso: junio-2009
Mensajes: 4
Antigüedad: 14 años, 10 meses
Puntos: 1
Respuesta: Me ayudan Con un buscador interno

"mira exactamente" te voy a dar el codigo que yo uso para una de mis paginas web y que se que funsiona.
El formulario es algo asi...
Código HTML:
<form name="search" action="/search.php" method="get" class="form">
              <input type="text" name="find" class="field" />
			  <input type="hidden" name="searching" value="yes" />
              <input type="submit" value="Go" name="search" class="button" />
 </form> 
Es bastante facil..pero ahora viene lo mas complicado

Código PHP:
<?
$searching
=$_GET['searching'];
$find=$_GET['find'];
$find=str_replace('"','&quot;',$find);
$find=str_replace("'","'",$find);
$find=str_replace("(","(",$find);
$find=str_replace(")",")",$find);
$find=str_replace("<","&lt;",$find);
$find=str_replace(">","&gt;",$find);
$find=str_replace("[","[",$find);
$find=str_replace("]","]",$find);
$find=str_replace("/","/",$find);


if (
$searching =="yes"

echo 
"<h1 class='pagetitle'>Search Result</h1>";


if (
$find == ""

echo 
"<p>You forgot to enter a search term</p>"
exit; 



include (
'connex.php');

$find strip_tags($find); 
$find trim ($find); 

echo 
'<div class="column1-unit">';

echo 
"<b>Searched For:</b> " .$find.'<hr/>'

$SQLquery 'SELECT * FROM tutorialehtml_content  WHERE content LIKE "%'.$find.'%" ';
$rezult mysql_query($SQLquery);
    while(
$rand mysql_fetch_array($rezult)) { 
    

echo 
'<h2><a href="/'.$rand['filename'].'" title="'.$rand['title'].'">'.$rand['title'].'</a></h2>';
echo 
$rand['metadesc'].'... <a href="/'.$rand['filename'].'" title="Go To This Article">Read More</a>';
echo 
'<br><hr>';



$anymatches mysql_num_rows($rezult); 
if (
$anymatches == 0

echo 
"Sorry, but we can not find an entry to match your query<br><br>"


echo 
'</div></div>';

?>
Lo malo es que esto no hace nada si no tienes toda la informacion de los archivos "gripe.html" y "holas.html " metida en la base de dato...pero voy a parar aqui porq esto no es lo que tu preguntas.

__________
Mi firma no sale, porq? hlp, pm pls