开发者

Make PHP to search everything

I was wondering how I would search more t开发者_Go百科ables in my search database to include city and search. City and search is already in my database all I need to do is search them, but i don't know how.

This is what i have so far:

//explode out search term
$search_exploded = explode(" ",$search);

foreach($search_exploded as $search_each) {

//construct query
$x++;
if ($x==1)
    $construct .= " keywords LIKE '%$search_each%'";
else
    $construct .= " OR keywords LIKE '%$search_each%'";
}


Change the code to:

foreach($search_exploded as $search_each) {
    //construct query
    $x++;

    if ($x==1)
        $construct .= " keywords LIKE 
            '%$search_each%' OR city LIKE '%$search_each%' or state LIKE 
            '%search_each%'";
    else
        $construct .= " OR keywords LIKE 
            '%$search_each%' OR city LIKE 
            '%$search_each%' or state LIKE '%search_each%'";
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜