我有以下功能
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";
}
}
这个想法是让函数返回一个带空格的聊天室号码。- 每次用户加入房间时,都会插入一条没有消息的行,状态为在线 - 每次用户离开房间时,都会插入一条没有消息的行,状态为离线 我现在正在尝试编写一个函数来检查是否有每个主题的任何备用房间 想法是选择已登录但未注销的用户数小于每个房间的最大聊天数的 room_num。有人可以帮我处理我的 $sqlii。
谢谢