Jump to content

Search by relevance


drisate

Recommended Posts

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)) {
// [...]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.