0

Iam new to PHP, trying to do personalized search engine it works fine with the single user... but simultaneously 2 user uses.. the values in the Variable showing wrong values.
Eg:
if user1 search "Apple" then $qry="Apple",
same time user2 search "orange" then $qry="orange"
that time the user1 will get the remaining stuffs related "orange".

function storewords($str,$id)
{
    $words= str_word_count($str,1);
    $cntstr = count($words);
    //echo $cntstr; 
    for($i=0;$i<$cntstr;$i++)
    {
        $allwords= $words[$i];
        $insert = "INSERT INTO freq (word,extra) VALUES ('".$allwords."','".$id."')";
        $add_member = mysql_query($insert);
    }
}

Which i have process of preprocessing, extracting concept for each user's content.. each user have different content. I think i have expressed my doubt in correct word, if no please excuse. Please help me, Thanks in advance

1 Answers1

0

You just have to store user id somehow, to get separate "searches" for each user later.

$insert = "INSERT INTO freq (userid,word,extra) VALUES (...)";

Then you should select from that table using SELECT with filter like this: "WHERE userid=$current_user_id"

Kamil
  • 13,363
  • 24
  • 88
  • 183