par
psaikopat » 08 sept. 2005, 17:20
Bien évidement a éditer avec ton script et tes bases mais c'est la structure a utiliser ...
<?php
$mot_cle=$_POST['mot_cle'];
//On remplace les (+)(")(,)(:) par des espaces
$mot_cle=strtolower($mot_cle);
$mots = str_replace("+", " ", trim($mot_cle));
$mots = str_replace("\"", " ", $mots);
$mots = str_replace(",", " ", $mots);
$mots = str_replace(":", " ", $mots);
//Mettre les mot dans un tableau
$tab=explode(" " , $mots);
$nb=count($tab);
//création de la requete pour rechercher les mots
$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("intranet",$sql);
//if ($result)
//{
if(mysql_num_rows($result) == 0)
{
echo '<html><body>';
echo "<center><b>Pas de résultat</b></center>";
echo "<br>";
echo "<center>Pour le mot : $mot_cle</center>";
echo '</body></html>';
}
else
{
echo '<html><body>';
echo "<center><b>Résultat(s)</b></center><br>";
echo '</body></html>';
while($row = mysql_fetch_array($result))
{
// echo $row["document"];
$url = $row["chemin"] . $row["document"] . "." . $row["extension"];
$point = $row["extension"];
echo '<html><body><br>';
echo " => <a href=\"$url\" target='_blank'>$url</a><br>";
echo '</body></html>';
}
mysql_free_result($result);
}
//}
?>
Bien évidement a éditer avec ton script et tes bases mais c'est la structure a utiliser ...
[php]<?php
$mot_cle=$_POST['mot_cle'];
//On remplace les (+)(")(,)(:) par des espaces
$mot_cle=strtolower($mot_cle);
$mots = str_replace("+", " ", trim($mot_cle));
$mots = str_replace("\"", " ", $mots);
$mots = str_replace(",", " ", $mots);
$mots = str_replace(":", " ", $mots);
//Mettre les mot dans un tableau
$tab=explode(" " , $mots);
$nb=count($tab);
//création de la requete pour rechercher les mots
$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("intranet",$sql);
//if ($result)
//{
if(mysql_num_rows($result) == 0)
{
echo '<html><body>';
echo "<center><b>Pas de résultat</b></center>";
echo "<br>";
echo "<center>Pour le mot : $mot_cle</center>";
echo '</body></html>';
}
else
{
echo '<html><body>';
echo "<center><b>Résultat(s)</b></center><br>";
echo '</body></html>';
while($row = mysql_fetch_array($result))
{
// echo $row["document"];
$url = $row["chemin"] . $row["document"] . "." . $row["extension"];
$point = $row["extension"];
echo '<html><body><br>';
echo " => <a href=\"$url\" target='_blank'>$url</a><br>";
echo '</body></html>';
}
mysql_free_result($result);
}
//}
?>[/php]