|
|
|
|
SAlut les gens (hé oui encore moi!!!)
Bon alors voici un script de moteur de recherche qui fonctionne a peu près a kel détail près...
<?php require_once('Connections/intranet.php'); ?>
<?php
$mot_cle=$_POST['mot_cle'];
$mots = str_replace("+", " ", trim($mot_cle));
$mots = str_replace("\"", " ", $mots);
$mots = str_replace(",", " ", $mots);
$mots = str_replace(":", " ", $mots);
$tab=explode(" " , $mots);
$nb=count($tab);
$sql="SELECT * FROM mot_cle WHERE mot LIKE \"%$tab[0]%\" ";
for ($i=1 ; $i<$nb ; $i++)
{
$sql.="$operateur mot_cle like \"%$tab[$i]%\" ";
}
$result = mysql_db_query($db,$sql);
if ($result)
{
if(mysql_num_rows($result) == 0) echo "<center><b>Pas de résultat</b></center>";
else
{
echo "<center><b>Résultat(s)</b></center><br>";
while($rows = mysql_fetch_array($result))
{
echo $row["document"];
$url = $row["chemin"];
$point = $row["extension"];
echo " | <a href=\"$url\">$url</a>";
}
mysql_free_result($result);
}
}
echo "La requete SQL execute est : $sql";
?>
$result = mysql_db_query($db,$sql);
Connections/intranet.php
<?php # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_intranet = "localhost"; $database_intranet = "intranet"; $username_intranet = "root"; $password_intranet = ""; $intranet = mysql_pconnect($hostname_intranet, $username_intranet, $password_intranet) or trigger_error(mysql_error(),E_USER_ERROR); ?> Erreur obtenue : Notice: Undefined variable: db in c:\program files\easyphp1-7\www\intranet\recherche.php on line 19 et ça : echo "La requete SQL execute est : $sql"; me donne ça si je tape test: La requete SQL execute est : SELECT * FROM mot_cle WHERE mot LIKE "%test%" |