我有以下功能
function availableChatRoom($topic_id){
$max_rooms = 2;
$max_users = 2;
$sqli = "SELECT COUNT(DISTINCT room_num) AS numRooms FROM forum_chat WHERE topic_id = $topic_id ";
$num_rooms = queryColumnVal($sqli, "numRooms");
$sqlii = "SELECT room_num, COUNT(user_id) AS numUsers FROM forum_chat
WHERE topic_id = $topic_id AND (status = online AND status = offline ) AND chat_msg =
GROUP BY room_num
HAVING numUsers < $max_users ORDER BY msg_date";
$num_rooms_with_spaces = mysqlNumRows($sqlii, "room_num");
queryColumnVal($sqlii, "room_num");
if($num_rooms == 0){
return 1;
时 时
elseif($num_rooms <= $max_rooms){
if($num_rooms_with_spaces == 0){
return $num_rooms + 1;
时 时
else{
return queryColumnVal($sqlii, "room_num");
时 时
时 时
else{
return "none";
时 时
时 时
the idea is for the function to return a chat room number with space. -Every time a user joins the room, a line with no msg is inserted with status online -Every time a user leaves the room a line with no msg is inserted with status offline I am now trying to write a function which checks if there are any spare rooms for each topic The idea is to select the room_num where the number of users who have logged in but not logged out is less than the maximum chatter per room. Can someone help me with my $sqlii.
谢谢 谢谢