I am yiibie. What I am trying to do is to retrieve data from my database, and for that i am using cDbCriteria
. I want to get the last 4 images from my database table which is named Event
. and then want to display those 4 images individually. I am using this method but not getting any result, please help me with this.
<?php
$Criteria = new CDbCriteria();
$Criteria->limit = 4;
$Criteria->order = "image DESC";
$Criteria->select = "id, image";
$Events = Event::model()->findAll($Criteria);
foreach ( (array)$Events as $Event)
{
$Event[1]=$image1;
$Event[2]=$image2;
$Event[3]=$image3;
$Event[4]=$image4;
}
?>
<div class="row">
<h3>Events</h3>
<div class="col-md-3">
<div class="thumbnail">
<img src="<?php echo $image1 ?>">
<div class="caption">
<a href="join.php"> <button class="btn btn-primary center-block">Join</button></a>
</div>
</div>
</div>