问题描述
我正在尝试使用查询生成器来显示基于当前登录用户以及每个团队中的成员的所有团队,以显示如下内容:
team logo | team name | member ign
image | dotatest3team_2 | dotafortest1
| dotafortest2
| dotafortest3
| dotafortest10
| dotafortest11
image | codtest2team | dotafortest1
| dotafortest2
| dotafortest3
| dotafortest10
| dotafortest11
以某种方式我得到的结果:
- 仅显示1个团队“ codtest2team”
- 它显示6个成员(我认为是从add_game表记录中提取),而不是5个成员(来自teammember_list表)
我已包含数据库here
下面是我当前的代码:
型号
return $this->db->table('team_list t1')
->join('teammember_list t2','t2.team_id = t1.team_id')
->join('add_game t3','t3.game_id = t2.game_id')
->join('game_list t4','t4.game_id = t3.game_id')
->where('t2.user_id',$user_id)
->get()
->getResultArray();
查看
<table class="table teams-list">
<thead class="thead-light">
<tr>
<th scope="col">Logo</th>
<th scope="col">Team Name</th>
<th scope="col">Members IGN</th>
</tr>
</thead>
<tbody>
<?php
$team_array = array();
foreach ($teams as $row) {
// Set title value
$team = $row['team_id'];
// Check if team value has already been used,proceed if not
if(!in_array($team,$team_array)) {
// Add team value to $team_array and echo team
$team_array[] = $team;
?>
<tr>
<th scope="row"><img src="<?php echo base_url('/public/uploads/img/'. strtolower($row['team_logo'])); ?>" alt="" /></th>
<td><?= $row['team_name']; ?></td>
<td>
<?php
foreach ($teams as $row) {
if($team == $row['team_id']) {
?>
<?= $row['ign']; ?>
<?php
}
}
?>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
我找不到哪里出错了。谁可以帮我这个事?预先感谢大家!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)