Hi, I need help with an algorithm to allocate rooms to people. I need to shuffle through a list of rooms to assign a room to a person and after the fourth person is assigned to the room, it should be out of the list(should be unavailable). I have not had any luck with PHP shuffling and sorting functions yet.

Any help (pointers, references, etc.) will greatly be appreciated.

Member Avatar for diafol

The php manual on php.net.
I would use a MySQL DB for this.
TABLES
Rooms: id, room_name
People: id, name, surname
Assigns: id, room_id, user_id

You simply add assigns as you allocate a person to a room
If the number of assigns for a room_id is < 4, display it, otherwise don't.

You'll need to look up mysql JOIN and COUNT clauses. It's not too difficult once you get to grips with basic MySQL.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.