模糊到什么程度呢?
sqltxt="select title from yourtable where key1 like '%".$keyword."%' or key2 like '%".$keyword."%';
mysql_query(sqltxt);

解决方案 »

  1.   

    更正一下$sqltxt="select title from yourtable where key1 like '%".$keyword."%' or key2 like '%".$keyword."%';
    mysql_query($sqltxt);
      

  2.   

    $keyword = $_REQUEST['keyword'];
    $query = sprintf("SELECT title FROM tablename WHERE title LIKE '%%%s%%'", $keyword);
      

  3.   

    select title from msgtable where locate('$keyword',key1)>0 or locate('$keyword',key2)>0
      

  4.   

    同意  gcs925(鸟倦飞而知还)
      

  5.   

    模糊到什么程度呢?
    $sqltxt="select title from yourtable where key1 like '%".$keyword."%' or key2 like '%".$keyword."%';
    mysql_query($sqltxt);
      

  6.   

    假如我想在title(是标题),key1(关键字1),key2(关键字2)他们加起来用%查询,应该如何写呢。谢谢。%号加在前面或加在后面有什么不同,???
      

  7.   

    $sqltxt="select title from yourtable where title like '%".$keyword."%' or key1 like '%".$keyword."%' or key2 like '%".$keyword."%';
    mysql_query($sqltxt);
    %加在前面意思就是前面可以是任意字符,加在后面就是后面可以是任何字符。