Hi, all:

Table News
__________________________
NewsID | Keywords  | News
-------|-----------|------
   1   |word1,word2| News1
-------|---------- |------
   2   |  word2    | News2
__________________________

I want to search this table based on the Keywords. the code is:

$split = explode(" ",$keywords);
$Num = 0;
  for($index=0;$index<count($split);$index++){
    $sql = "SELECT * FROM News WHERE Keywords LIKE '%$split[$index]%';
    $result = mysql_query($sql) or die(mysql_error());
    while($myrow = mysql_fetch_array($result)){
      $Num = $Num +1;
      $NewsID = $myrow["NewsID"];
      $News = $myrow["News"];
    echo $Num . ". " . $News . "<br>";
    }//end while
  }//end for

If the keywords inputted from user are: "word2, word1", it will reture News1
twice:
    1. News1
    2. News2
    3. News1
I am trying to use array_diff, but I don't know how to do it, would anyone
please help me? Thanks a lot.

Fang


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to