作者:漫湾镇团委 | 来源:互联网 | 2023-05-18 01:27
I want to achieve this
我想实现这一目标
- john -> sub user
- 约翰 - >子用户
- john -> sub user
- 约翰 - >子用户
- mark -> sub user
- mark - > sub user
- mark -> sub user
- mark - > sub user
- dave -> sub user
- 戴夫 - >子用户
- dave -> sub user
- 戴夫 - >子用户
But this was the unexpected output
但这是意料之外的输出
- john -> sub user
- 约翰 - >子用户
- john -> sub user
- 约翰 - >子用户
Only the username john
has appeared
只有用户名john出现了
// Get all the users
$s = $sqlConnection->query('SELECT * FROM accounts');
while ($row = $s->fetch_assoc())
{
$uarr = explode(',', $row['username']);
foreach ($uarr as $ueach)
{
// Get all the direct sales
$query = "SELECT *";
$query .= " FROM accounts ACC";
$query .= " INNER JOIN info INF ON ACC.user_id = INF.iuid";
$query .= " INNER JOIN sales SAL ON ACC.user_id = SAL.suid";
$query .= " WHERE SAL.mentor = '$ueach'";
$s = $sqlConnection->query($query);
if (!$s)
{
die($sqlConnection->error);
}
while ($row = $s->fetch_assoc())
{
echo $ueach . ' -> ' . $row['username'] . '
';
}
}
}
Here's the database structure
这是数据库结构
accounts
账户
user_id | username |
--------+----------+
1 | john |
--------+----------+
2 | mark |
--------+----------+
3 | dave |
--------+----------+
info
信息
iuid |
---------+
1 |
---------+
2 |
---------+
3 |
---------+
sales
销售
suid | mentor |
--------+----------+
1 | john |
--------+----------+
2 | mark |
--------+----------+
3 | dave |
--------+----------+
2 个解决方案