Displaying Multiple Images From Database

Hello guys!

What i am trying to do, is retrieve multiple images from database table and display them in my view. I tried to do that by creating a function actionDisplaySavedImage in my controller. Here is my code:

 public function actionDisplaySavedImage()


            $Criteria = new CDbCriteria();

            $Criteria->select="start, end, ID, enabled, photo";

            $Criteria->order = "end";

            $records = Packages::model()->findAll($Criteria);

            foreach ($records as $rec) 


                header('Content-Type: jpeg');

                echo $rec->photo;



The problem is that if i call this action it only displays one image.


But if i try

echo $rec->ID

instead of

echo $rec->photo

it works ok.


What’s wrong??? There is nothing wrong with my images, i can display each of them seperately.

If this is not going to work, is there any other way to retrieve multiple images from db and display them to my view?

This is your error. Just don’t do that. A database is a poor substitute for a file system.

Your browser is only going to render one image if you tell it to expect image content. If you need to show multiple images on the same page, use an HTML document.

I want to display only the images from the records that are currently active(enabled=1), so if user clicks on them, they will be redirected to the corresponding page.

How can this be done if i use html document?