drisate Posted May 11, 2011 Share Posted May 11, 2011 Hey guys i created a search engin on my website and i need to filter out the result by relevance ... So fare my code looks like this: if ($_GET[q]){ // On sépare le nom et le prénom $arr = explode (' ', $_GET[q]); $where .= "("; foreach($arr as $mot){ if ($_GET[type]=='1'){ $where .= "evenement.occ like '%$mot%' or evenement.description like '%$mot%' or "; }else{ $where .= "membre.nom like '%$mot%' or membre.prenom like '%$mot%' or "; } } $where = substr($where, 0, -3); $where .= ")"; } if ($_GET[eve_categ]){ if ($where){ $where .= " and ("; }else{ $where .= " ("; } foreach ($_GET[eve_categ] as $key => $value){ $eve_categ .= "-$value-"; $where .="evenement.eve_categ = '$value' or "; } $where = substr($where, 0, -3).') and evenement.user_id=membre.id'; } if ($where==""){$where='1=1';} if ($_GET[type]=='1'){ $select = mysql_query("SELECT * FROM membre, evenement WHERE $where and membre.id=evenement.user_id limit $offset,$nombre_par_page"); }else{ $select = mysql_query("SELECT * FROM membre WHERE $where limit $offset,$nombre_par_page"); } while ($recherche = mysql_fetch_array($select)) { // [...] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.