$sql = "SELECT * FROM groups WHERE id IN (SELECT group FROM groupmembers WHERE user = $my_userid)";
好吧,groups
的结构如下:name, id, privacy
,组成员的结构如下:group, user
变量$my_userid
已经定义,其值为1。
我正在尝试执行上面的sql,然后包含一个将回显组名的文件,我已将自己添加到2个组中,因此我应回显test1和test2,包括的文件有效,我尝试了两次,只是看它是否有问题,不是。我看不到出什么问题了,我已经在这里寻找修复程序,但是没有找到它。整个php代码如下:
<?php
$sql = "SELECT * FROM groups WHERE id IN (SELECT group FROM groupmembers WHERE user = $my_userid)";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$g_name = $row['name'];
$g_id = $row['id'];
include 'files/social/group.php';
}
} else {
// Nothing to display, user is not in any group.
}
?>