<?php
$keyword= 'keyword1 keyword2';
$search_word=explode(' ',$keyword);
foreach ($search_word as $word){
//echo $word."<br />";
$where_list[]="`question` LIKE '%$word%'";//SQL
$where_clause = implode(' OR ',$where_list);
}
if(!empty($where_clause)){
$search_query .= " WHERE $where_clause";
}
echo $search_query; //WHERE `question` LIKE '%keyword1%' OR `question` LIKE '%keyword2%'
?>
沒有留言:
張貼留言