At this point, I can see all listed cities. I would like to see only those in which there is an order. How to do it? Thank you in advance for any help! The script is written in cakephp, unfortunately I'm just learning and mastering this framework from scratch. I hope it is not complicated, or if I can do it on this code, do you need to rebuild the controller?
<?php foreach ($list_city as $city): ?>
<span class="cities"><?= h($city->name) ?></span>
<?php $licz=1; foreach ($orders as $order): ?>
<?= '<table>' ?>
<?php if($order->customer->city->name == $city->name): ?>
<td style="width: 10%; text-align: center;">
<span>
<?= $this->Form->postLink('<span class="status-icon icon-circle-empty"</span>', ['action' =>'fajrant', $order->id],
['title'=>__('Dostarczono?'), 'escape'=>false,
'confirm' => __('Czy dostarczono zamówienie: {0}?', $order->customer->address)]) ?>
</span>
</td>
<td>
<span>
<?= h($order->customer->address) ?>
</span>
<?php if($order->product_1>0) {
echo ('<span class="produkt_butt">');
echo $this->Number->format($order->product_1) . ' szt' . '</span>'; }
if($order->product_2>0) {
echo ('<span class="produkt_butt1">');
echo $this->Number->format($order->product_2) . ' szt' . '</span>'; }
?>
<span><?= h($order->description) ?></span>
</td>
<td>
<span><?= $this->Number->currency($order->price,'',['precision' => 0]) ?></span>
</td>
<td>
<a href="tel:<?= h($order->customer->phone); ?>" target="_blank"></a>
</td>
<td>
<span><?= $this->Html->link(__('') . '', ['action' =>'view', $order->id], ['title'=>'Zobacz zamówienie', 'class'=>'chev-icon icon-chev-right']) ?></span>
</td>
<?php endif ?>
<?= '</table>' ?>