我正在尝试使用 PHP
从数据库获取数据,这是 Sql 请求,您会看到我有 3 个表,但在表 Milestoneevent
中我有各种值列 libelle
所以我想像这样显示
Id num libelle1 libelle2 libelle3 ..... sql reql request and php
select DISTINCT file.num,file.id as filenumber,file.numlta,milestones.id,milestones.libelle,milestoneevent.idmilestone,milestoneevent.dat,milestoneevent.idfile from file,milestones,milestoneevent where milestoneevent.idfile=FILE.num and milestoneevent.idmilestone=milestones.id
while (row=mysqlfetchassoc(
rs_result)) {
//print_r( $row ); // debug code ?>
<tr>
<td><input type='checkbox' name="approve[]" id="check" value=<?php echo $row['num']?>></td>
<td><?php echo $row['filenumber']; ?></td>
<td><?php echo $row['numlta']; ?></td>
<td><?php echo $row['designation']; ?></td>
<td><?php echo $row['libelle']; ?></td>
<td><?php echo $row['milestonedate']; ?></td>
</tr>
在图中,您可以看到行cqn
在不同日期的libelle
列有多个值
编辑
根据评论中的要求,这是我的预期输出:
<小时/>
我被迫在这里添加图片,因为评论讨论中无法添加它
最佳答案
您可以使用GROUP_CONCAT ,在您的查询中:
select...,GROUP_CONCAT(milestones.libelle SEPARATOR ';'),..FROM....WHERE...GROUP BY milestones.id
关于javascript - 连接表显示不重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35744039/