Click here to Skip to main content
15,068,879 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Firstly sorry for my English. I want to send random Messaging but there are some conditions.

I have two table. Users(id, name, tags) Messages(id, sender, received, message)

Tags column (book, movie, travel) max 10 tags. The data is kept this way.

When an active user sends a message. Forward the message to the X user. Rules : 1. X user: A user who has never received a message and x user's tags must most similar the sender and x user must have never received a message from an Active user before.

I hope I could tell. Thank you

What I have tried:

PHP
$id = $_SESSION["id"];
$Activeuserstags = explode(",", $_SESSION["tags"]);

                $query=$db->prepare("select id,tags from users where id!=? and id not in (select receivedid from messages)");
                $query->execute(array($id));
                $user = $query->fetchAll(PDO::FETCH_ASSOC);
                if($user){
                foreach($user as $row){
                     $randomusertags=explode(",", $row["tags"]);
                     $result = array_intersect($Activeuserstags, $randomusertags);
                     if(count($result)>0){

                         // there is similar tags
                     }else{

                         // there is no similar tags
                     }


                  }
Posted
Updated 25-Nov-18 20:55pm
v2

1 solution

If this is not easy. Please look this.

*I want to find the user whose interests are most similar to me.


Tags coloumn (book,movie,chat) There's a comma between them.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900