Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

Let a User interact with other Users

Hi!
I need your help regarding the following: I'm coding a website where users can search for other users with the same interest. It works by letting a user fill out a form with his interests (radio-buttons, so only a limited amount of posibillities). Every posibillity has an ID. For example, user fills out the form and gets ID 37, his name is pushed in a mysql database in row number 37. If there are 3 users in the same row, every user gets a notification with a link to the profile of the 2 other ones with the same ID, so they can connect.
My questions are:

  1. How to detect if there are 3 users in a row? (was thinking about checking everytime a user enters the db)

  2. How to interact with the individual users and sending them a notification? (Doesn't need to be a fancy system, only the links popping up at the website) Every user has a unique id btw.

  3. Is this even possible in PHP?



Thank you!
Veni, Vidi, Vici


You would need to use a pivot table for this.

Ideally it would look something like this

Tables:
interests | id | interest_name
users | id | password | username
interest_users | id | user_id | interest_id

The intetest_users makes the link between the users and the interests then you just fetch all the users from the interest_users table with a join.

And for messages:

messages| id | message
users | id | password | username
messages_users| id | user_id | message_id
[Image: m7EgqG6.png]
Quote:If there are 3 users in the same row


That's not how databases work.
(Oct 2, 2015 06:05 AM)Αlpha Wrote:  You would need to use a pivot table for this.

Ideally it would look something like this

Tables:
interests | id | interest_name
users | id | password | username
interest_users | id | user_id | interest_id

The intetest_users makes the link between the users and the interests then you just fetch all the users from the interest_users table with a join.

And for messages:

messages| id | message
users | id | password | username
messages_users| id | user_id | message_id

So let the user repeat a script and when the number of rows in interest_users with the same interest id is > 2, fetch the profile link and show it to them?
Veni, Vidi, Vici


(Oct 2, 2015 07:22 AM)Sandler Wrote:  So let the user repeat a script and when the number of rows in interest_users with the same interest id is > 2, fetch the profile link and show it to them?

Also depends on the amount of users that are in the DB.
For example there are 1k users in the DB you wouldn't want to show your user 1k users.
Let's say interest id = 1 which is linked to interest name gaming, and the current user's interest is also gaming you can do a join on that table where all the other users interests are also gaming
[Image: m7EgqG6.png]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[PHP] by lmorraMay 25, 2014 11:23 PM 10 221 May 25, 2014 11:23 PM
Last Post: lmorra
[PHP] by badbrainsMar 21, 2013 06:18 PM 8 335 Mar 21, 2013 06:18 PM
Last Post: badbrains