ในภาพทำเป็นสไลด์โชว์ครับ ปัญหาคือ อยากทราบวิธีการวนลูป ให้รูปแรกเป็นสินค้าที่1 รูปที่สองเป็นสินค้าที่2 รูปที่สามเป็นสินค้าที่3
โค้ดที่ใช้
Code: Select all
<div class="slider demo">
<div>
<center>
<?php foreach ($productsnew as $product):?>
<?php
$i=1;
while($i<=2)
{
echo '<img src="=img_products/'. $product['image'] .'" width=100px height=100px/>';
?>
</div>
<center><div> <?php echo '<img src="=img_products/'. $product['image'] .'" width=100px height=100px/>';?> </div></center>
<center><div> <?php echo '<img src="=files/img_products/'. $product['image'] .'" width=100px height=100px/>';?></div> </center>
<?php
$i++;
}
?>
<?php endforeach;?>
</div>
Code: Select all
class ModShowProductNewItem
{
public function newItem()
{
$db = Joomla\CMS\Factory::getDbo();
$query = $db ->getQuery(true)
->select('*')
->from('products')
->order('product_id DESC ');
$db->setQuery($query);
$items = $db ->loadAssocList();
return $items;
}
}