如何在我的画廊/旋转木马顶级餐厅展示?我希望每个人都能获得第1,第2,第3,第4,第5等级。我能够获得前5名,但不知道如何把它们放在我的幻灯片上。可能吗?
型号:
public function getTopResto($highest=TRUE)
{
$Order = $highest ? 'DESC' : 'ASC';
$q = $this->db
->select('r.*')
->select('AVG(ra.rate) avg_rating', FALSE)
->from('restaurants r')
->join('ratings ra', 'r.id = ra.restoid', 'left')
->group_by('r.id')
->order_by('avg_rating', $Order)
->limit('5')
->get();
return $q->result_array();
}
查看:
<div class="feature">
<div class="container">
<div class="carousel-container">
<div id="carousel">
<h2 class="topresto">Top Restaurants</h2>
<div class="carousel-feature">
<a href="#"><img class="carousel-image" alt="Image Caption" src="<?php echo base_url();?>assets/images/logos/american/Aresto4-logo.png"></a>
<div class="carousel-caption">
<p>
1. *insert restoname
</p>
</div>
</div>
<div class="carousel-feature">
<a href="#"><img class="carousel-image" alt="Image Caption" src="<?php echo base_url();?>assets/images/logos/american/Aresto9-logo.png"></a>
<div class="carousel-caption">
<p>
2. *insert restoname
</p>
</div>
</div>
<div class="carousel-feature">
<a href="#"><img class="carousel-image" alt="Image Caption" src="<?php echo base_url();?>assets/images/logos/american/Aresto7-logo.png"></a>
<div class="carousel-caption">
<p>
3. *insert restoname
</p>
</div>
</div>
<div class="carousel-feature">
<a href="#"><img class="carousel-image" alt="Image Caption" src="<?php echo base_url();?>assets/images/logos/dessert/Dresto1-logo.png"></a>
<div class="carousel-caption">
<p>
4. *insert restoname
</p>
</div>
</div>
<div class="carousel-feature">
<a href="#"><img class="carousel-image" alt="Image Caption" src="<?php echo base_url();?>assets/images/logos/american/Aresto6-logo.png"></a>
<div class="carousel-caption">
<p>
5. *insert restoname
</p>
</div>
</div>
</div> -->
<div id="carousel-left"><img src="<?php echo base_url();?>assets/featurecarousel/images/arrow-left.png" /></div>
<div id="carousel-right"><img src="<?php echo base_url();?>assets/featurecarousel/images/arrow-right.png" /></div>
</div>
</div>
</div>
答案 0 :(得分:0)
我认为你应该将滑块图像的路径存储在餐馆餐桌上。由于您已经在订购表格结果,所以您要做的就是这样取:
<?php foreach($rates as $rate) : ?>
<div class="carousel-feature">
<a href="#"><img class="carousel-image" alt="Image Caption" src="<?php echo base_url($rate->path_to_image);?>"></a>
<div class="carousel-caption">
<p>
1. $rate->restaurant_name
</p>
</div>
</div>
<?php endforeach; ?>