<p class="gallery">
    <?php foreach ($photos_patient as $ph) { ?>

        <?php if ($ph['ph_url'] != null) { ?>
            <?php if (file_exists(PUBPATH . "global/uploads/" . $ph['ph_url'])) { ?>
                <a href="<?= base_url() ?>global/uploads/<?php echo $ph['ph_url'] ?>" title="اضغط هنا لعرض الصورة">
                    <img src="<?= base_url() ?>global/uploads/<?php echo $ph['ph_url'] ?>" alt=""/>
                    <br />
                </a>

                <?php
            }
        } else {
            ?>
            <a href="javascript:void(0)">
                <img src="<?= base_url() ?>global/site/data/images(1).jpg"alt="" /></a>
        <?php } ?>
    <?php } ?>
</p>