I’m trying to make an application that pairs two available users by selecting them randomly from a database and then making them unavailable (so they can’t be selected again).
I was wondering how I could select them and then pair them?
I’ve got the following database structure.
USERS
| id | autoincrement, primary key
| user_id | user's ID
| connected | available, connecting, chatting
ROOMS
| id |
| room_name |
| room_id |
| user_id | first user connected
| user_id2 | second user connected
I’m not making rooms, I’m simply trying to pair users and send them to a room.
Do you mean join the records?
You could do something like:
123 = a room id.
EDIT:
Here is a way to update a Rooms record with two random Users
I have tested this and it seems to work. This will keep you from having duplicate users: