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.
mysql_query returns false for error. You can check the count of updated rows using mysql_affected_rows
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With