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
| <?php
if (!isset($_GET['debut'])) $_GET['debut'] = 0;
$nb_affichage_par_page = 1;
// Préparation de la requête avec LIMIT
$sql1 = 'SELECT accontact, public, description, activite, adresse, adresse2, commentaire FROM aide_ac, aide_st where aide_ac.structure=aide_st.s_clef';
if (isset($_SESSION['public'])&&($_SESSION['public'])!="Choisir une activité dans la liste")
{
$sql1 .= ' AND public = "'.$_SESSION['public'].'"';
}
//if mot clef---------------------------------------posant problème-----
if (isset($_SESSION['mot'])&&($_SESSION['mot'])!="")
{
$_SESSION'mot'] = explode(" ",$_SESSION['mot']);
// On compte le nombre de mots entrés par le visiteur
$_SESSION'nbr_mot'] = count($_SESSION['mot'] );
$sql1 .= ' AND (adresse2 LIKE "%'.strtolower($_SESSION['mot'][0]).'%" OR adresse LIKE "%'.strtolower($_SESSION['mot'][0]).'%")';
$i = "1";
while ($i<$_SESSION['nbr_mot'])
{
// On specifie la methode OR ou AND et on recherche
$sql .= ''.$_SESSION['methode'].' (accontact LIKE "%'.strtolower($_SESSION['mot'][$i]).'%"
OR adresse LIKE "%'.strtolower($_SESSION['mot'][$i]).'%"
OR adresse2 LIKE "%'.strtolower($_SESSION['mot'][$i]).'%"
OR specifique LIKE "%'.strtolower($_SESSION['mot'][$i]).'%")';
// On increment la variable $i
$i++;
}
}//fin if mot-clef-------------------------------
$sql1 .=' ORDER BY activite ASC LIMIT '.$_GET['debut'].','.$nb_affichage_par_page;
// on exécute la requête
$req1 = mysql_query($sql1) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
// on va scanner tous les tuples un par un
while ($data = mysql_fetch_array($req1)) {
// on affiches les résultats dans la table
echo '<table><tr><td class="txtgo" width="20%">Organisateur</td><td class="txtp" colspan="3" align="left">', stripslashes(htmlentities(trim($data['s_nom']))) , '</td>';
echo '<tr><td class="txtgo">Activité proposée</td><td class="txtp" colspan="3" align="left">' , stripslashes(htmlentities(trim($data['activite']))) , '</td>';
echo '<tr><td class="txtgo">Description</td><td class="txtp" colspan="3" align="left">' , stripslashes(htmlentities(trim($data['description']))) , '</td></table>';
?> |
Partager