<?php if (!empty($images)) { foreach ($images as $image): echo $html->image('uploads' . DS . 'images' . DS . $image['Image']['img_file'], array('alt' => 'Gallery Image')); ?> <br/> <?php echo $this->Html->link(__('Delete', true), array('action' => 'delete', $image['Image']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $image['Image']['id'])); endforeach; }else { echo $this->Html->link(__('Add Profile Image', true), array('action' => 'add')); } ?>
Hi How do I only show a single image from the database without using the foreach loop. For example, i have an image in the database “default.jpg”. if user did not add any image, a default image will be displayed. then if the user chose to add a profile image, the default image will be replaced to the new image the user selected. then if the user has deleted their profile image, the default image will be displayed.
1 Answer