1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| <?php
include ('secure.php');
include ('mysqlconnect.php');
$projet = $_POST['btprojet'];
$search = $_POST['textfieldsearch'];
if(isset($search) && trim($search) != '')
{
$search = str_replace('+', ' ', trim($search));
$search = str_replace('\'', ' ', $search);
$search = str_replace(',', ' ', $search);
$search = str_replace(':', ' ', $search);
$tabsearch = explode(' ' , $search );
//on compte le nombre de mots
$nbsearch = count($tabsearch);
//on prépare la requête SQL.
$sql = "select *
from fiches
where numFiche ='".$tabsearch[0]."'
or nomFiche like %'".$tabsearch[0]."'%
or datecreaFiche ='".$tabsearch[0]."'
or loginF ='".$tabsearch[0]."'
or descriptifFiche like %'".$tabsearch[0]."'%
or resolutionFiche like %'".$tabsearch[0]."'%
or nomProjet ='".$search."'
or nbhresolution = '".$tabsearch[0]."'
or enseigne = '".$tabsearch[0]."'
or privee ='".$tabsearch[0]."'
or emailF = '".$tabsearch[0]."'";
// on boucle pour integrer tous les mots dans la requête
$sql = "select * from fiches where 1";
for ($i = 0; $i < $nb; $i++)
{
$sql .= " AND ( numFiche='".$tabsearch[i]."'
or nomFiche like %'".$tabsearch[i]."'%
or datecreaFiche ='".$tabsearch[i]."'
or loginF ='".$tabsearch[i]."'
or descriptifFiche like %'".$tabsearch[i]."'%
or resolutionFiche like %'".$tabsearch[i]."'%
or nomProjet '".$search."'
or nbhresolution = '".$tabsearch[i]."'
or enseigne = '".$tabsearch[i]."'
or privee ='".$tabsearch[i]."'
or emailF = '".$tabsearch[i]."' )";
}
// on execute la requête SQL.
$result = mysql_query($sql);
if ($result)
{
if (mysql_num_rows($result) == 0)
{
// Si il n'y a pas de résultats
echo '<script language=javascript> alert ("Pas de résultat");</script>';
echo '<SCRIPT LANGUAGE="JavaScript">document.location.href="accueil.php" </SCRIPT>';
exit;
}else{
echo "<select name='searchselection'>";
while($datafichiers = mysql_fetch_assoc($result))
{
echo '<option>'.$row['nomFiche'].'</option>';
echo '<br>';
}
}
echo'</select>';
}
mysql_free_result($result);
}else{
echo '<script language=javascript> alert ("Indiquez un mot clé pour effectuer une recherche");</script>';
echo '<SCRIPT LANGUAGE="JavaScript">document.location.href="accueil.php" </SCRIPT>';
exit;
}
?> |
Partager