The process I want to do; I'm breaking data from the database using the Explode process. "SELECT * FROM roomsFeatures
WHERE slug
= '$foreachItem'". Everything's up to here. For example there are 15 data, I need to implement foreach in smarty. Below are my codes
My Explode Code [roomsController.php]
$features = explode("|", $getdata['roomFeatures']);
foreach($features as $feature){
$getFeature = $connection->prepare("SELECT * FROM roomsFeatures WHERE slug = '$feature'");
$getFeature->execute();
$getFeature = $getFeature->fetch();
print_r($getFeature);
}
##RESULT 15 ROW
Array
(
[id] => 1
[0] => 1
[name] => Yatak Odası
[1] => Yatak Odası
[slug] => yatakodasi
[2] => yatakodasi
[miniDescription] => Çift ya da tek kişilik seçenekleri, konforlu ve ergonomik yatakları, ihtiyaç dahilindeki ek servisleri ile hizmetinizdedir.
[3] => Çift ya da tek kişilik seçenekleri, konforlu ve ergonomik yatakları, ihtiyaç dahilindeki ek servisleri ile hizmetinizdedir.
[icon] => fas fa-tv propertyIcons
[4] => fas fa-tv propertyIcons
[createAt] => 2019-03-26 21:12:34
[5] => 2019-03-26 21:12:34
)
Array
(
[id] => 2
[0] => 2
[name] => Banyo
[1] => Banyo
[slug] => banyo
[2] => banyo
[miniDescription] => Hijyenik yapısı ve konforlu kullanımı ile hizmetinizdedir. Tüm odalarda olduğu gibi Standart Oda banyolarında ihtiyacınız olabilecek tüm materyalleri bulabilirsiniz.
[3] => Hijyenik yapısı ve konforlu kullanımı ile hizmetinizdedir. Tüm odalarda olduğu gibi Standart Oda banyolarında ihtiyacınız olabilecek tüm materyalleri bulabilirsiniz.
[icon] => fas fa-shower propertyIcons
[4] => fas fa-shower propertyIcons
[createAt] => 2019-03-26 21:13:37
[5] => 2019-03-26 21:13:37
)
..
.
How do I include the TPL file and the foreach query from the foreach? I couldn't make the connection between the controller and the TPL.
<div class="col-xl-3 roomProperties">
<div class="propertyFunctions"><i class="{$item.icon}"></i>
<h4 class="propertyHeader">{$item.name}</h4>
<p class="propertyText">{$item.miniDescription}</p>
</div>
</div>
Must be tpl File
{foreach $fromSomewhereArray as $item}
<div class="col-xl-3 roomProperties">
<div class="propertyFunctions"><i class="{$item.icon}"></i>
<h4 class="propertyHeader">{$item.name}</h4>
<p class="propertyText">{$item.miniDescription}</p>
</div>
</div>
{/endforeach}