So i wanna pairing users only in PHP:
First, get one avaliable user id //right now not random
mysql_query('SELECT id FROM users WHERE state="0" LIMIT 1'); //state 0 = user avaliable, 1 = talking/playing with someone
$available_id = stuffs to get id from query
And then update:
$result = mysql_query('UPDATE INTO users SET state="1" WHERE (id=$available_id OR id=$my_id) AND state="0"');
if $result == false then it mean that no one row has updated. So back to First step,
if $result == true then what? it can mean that my row has updated or available user, or both. I am confused how to done with it.
Try this code