데이터베이스에서 일부 데이터가 반환되지만 현재는 모든 데이터를 하나의 큰 목록으로 반환합니다.범주 별 SQL 결과 분할
데이터에는 모든 커플 항목에 대한 카테고리 이름이 있습니다. 카테고리가 지정된 모든 항목 그룹을 분리하고 싶습니다.
Example:
test1 (has category testing)
test2 (has category testing)
test3 (has category testing123)
이러한 결과는 단지 하나 개의 큰 목록으로 보여, 나는 결과처럼되고 싶습니다
testing:
test1
test2
testing123:
test3
내가 이걸 어떻게해야합니까?
내 코드는 지금처럼 (에만 관련 부품) :
while ($row_items = mysqli_fetch_assoc($res_items)) {
$checklist = '';
if ($row_items['checkpoints'] != '') {
$check = explode(',', $row_items['checkpoints']);
foreach($check as $list) {
$checklist .= '
<li class="cataloguslist">
<i style="color:#e88f41;" class="fa fa-check-square" aria-hidden="true">
</i> '.$list.'</li>';
}
}
echo '
<div class="col-lg-2 col-md-3 col-sm-6 col-xs-6 portf">
<a class="fancybox" href="../../catalogus/'.$row_items['afbeelding'].'">
<div class="gallery-item">
<div class="image">
<img src="../../catalogus_icons/'.$row_items['afbeelding'].'.jpg" alt="" style="border:1px solid #ccc;" class="img-responsive" />
</div>
<div class="bottom-info" style="min-height:200px;">
<div class="name">'.$row_items['naam'].'</div>
<ul style="margin-left:35px;margin-top:10px;">'.$checklist.'</ul>
<a href="contact.php">
<button class="contact_button buttoncontact btn-primary" style="border-radius:2px;">
Vraag offerte aan
<span class="icon-mail-alt"></span>
</button>
</a>
<div class="contactlink">
<a href="contact.php">Neem contact op</a>
</div>
</div>
</div>
</a>
</div>';
}
모든 결과가 cat
같은 id
및 카테고리 이름을 가진 테이블 (producten_cats에 연결 데이터베이스에 cat
행을 가지고 그것은 tablerow 이름으로 aswell에 :. naam
,