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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
<?php
include('connexion.inc.php');
$Mot = addslashes($_POST['recherche']);
if (($Mot == "")||($Mot == "%"))
{
echo "<tr>
<td>Veuillez entrer un mot clé s'il vous plaît!</td>
</tr>
";
}
else {
// On selectionne les enregistrements contenant le mot recherché dans le contenu des tables
$query = "
(SELECT id_presentation FROM web_presentation WHERE contenu LIKE \"%$Mot%\" OR titre LIKE \"%$Mot%\" AND langue='fr')
UNION
(SELECT id_contrat FROM web_contrat_tranquillite WHERE contenu LIKE \"%$Mot%\" OR titre LIKE \"%$Mot%\" AND langue='fr')
UNION
(SELECT id FROM web_depannage_info WHERE contenu LIKE \"%$Mot%\" OR titre LIKE \"%$Mot%\" AND langue='fr')
UNION
(SELECT id FROM web_install_parc WHERE contenu LIKE \"%$Mot%\" OR titre LIKE \"%$Mot%\" AND langue='fr')
UNION
(SELECT id FROM web_intranet_extranet WHERE contenu LIKE \"%$Mot%\" OR titre LIKE \"%$Mot%\" AND langue='fr')
UNION
(SELECT id FROM web_logiciel_app WHERE contenu LIKE \"%$Mot%\" OR titre LIKE \"%$Mot%\" AND langue='fr')
UNION
(SELECT id FROM web_pourquoi_site WHERE contenu LIKE \"%$Mot%\" OR titre LIKE \"%$Mot%\" AND langue='fr')
UNION
(SELECT id FROM web_sauvegarde_donnees WHERE contenu LIKE \"%$Mot%\" OR titre LIKE \"%$Mot%\" AND langue='fr')
UNION
(SELECT id_webmastering FROM web_webmastering WHERE contenu LIKE \"%$Mot%\" OR titre LIKE \"%$Mot%\" AND langue='fr')
";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
$Nombre = $row[0];
// Si aucun enregistrement n'est retourné, on affiche un message adéquat
if ($Nombre == "0")
{
echo "
<tr>
<td>
<p class=\"gras_rouge\">Désolé, aucun résultat ne correspond à votre recherche : $Mot</p>
</td>
</tr>
";
}
else { // Sinon, on affiche le nombre d'enregistrements correspondant et les résultats eux-mêmes
$query = "
(SELECT id_presentation, titre, lien FROM web_presentation WHERE contenu LIKE \"%$Mot%\" OR titre LIKE \"%$Mot%\" AND langue='fr')
UNION
(SELECT id_contrat, titre, lien FROM web_contrat_tranquillite WHERE contenu LIKE \"%$Mot%\" OR titre LIKE \"%$Mot%\" AND langue='fr')
UNION
(SELECT id, titre, lien FROM web_depannage_info WHERE contenu LIKE \"%$Mot%\" OR titre LIKE \"%$Mot%\" AND langue='fr')
UNION
(SELECT id, titre, lien FROM web_install_parc WHERE contenu LIKE \"%$Mot%\" OR titre LIKE \"%$Mot%\" AND langue='fr')
UNION
(SELECT id, titre, lien FROM web_intranet_extranet WHERE contenu LIKE \"%$Mot%\" OR titre LIKE \"%$Mot%\" AND langue='fr')
UNION
(SELECT id, titre, lien FROM web_logiciel_app WHERE contenu LIKE \"%$Mot%\" OR titre LIKE \"%$Mot%\" AND langue='fr')
UNION
(SELECT id, titre, lien FROM web_pourquoi_site WHERE contenu LIKE \"%$Mot%\" OR titre LIKE \"%$Mot%\" AND langue='fr')
UNION
(SELECT id, titre, lien FROM web_sauvegarde_donnees WHERE contenu LIKE \"%$Mot%\" OR titre LIKE \"%$Mot%\" AND langue='fr')
UNION
(SELECT id_webmastering, titre, lien FROM web_webmastering WHERE contenu LIKE \"%$Mot%\" OR titre LIKE \"%$Mot%\" AND langue='fr')
";
$result = mysql_query($query);
// Si un seul enregistrement est trouvé, on affiche un message au singulier
if ($Nombre == "1")
{
echo "
<tr>
<td>
<p class=\"gras_rouge\">Un article correspond à votre recherche : $Mot</p>
</td>
</tr>
";
}
// Dans le cas contraire le message est au pluriel...
else
{
echo "
<tr>
<td>
<p class=\"gras_rouge\">$Nombre articles correspondent à votre recherche : $Mot</p>
</td>
</tr>
";
}
while($row = mysql_fetch_object($result))
{
echo "
<tr>
<td class=\"noir_gras\">$row->titre
<br/><a href=\"../$row->lien\" class=\"lien\">Aller dans cette rubrique</a><br/><br/>
</td>
</tr>
";
}
}
}
?> |
Partager