oop - PHP elseif question -
currently have following section of code:
<?php if($sales_pages): ?> <?php foreach($sales_pages $sale): ?> <div id ="sales"> <span class"thumbnail"><a href="<?=base_url()?>page/sales/viewsale/<?=$sale->id?>"><img class="thumbnailimg" src="<?=base_url()?>includes/uploads/sales/thumbs/<?=$sale->thumbname?>" alt=""/></a> <span class="location"><?= $sale->location?></span> <span class="price"><?= $sale->price?></span> </span> </div> <?php endforeach; ?>
what trying following:
when there 0 sales (fetched database) in foreach code display message
is elseif correct way this?
no. should use else
. it's same saying elseif(true)
. you'll end like:
<?php if($sales_pages): ?> <?php foreach($sales_pages $sale): ?> print sale <?php endforeach; ?> <?php else: ?> nothing here... <?php endif; ?>
you can (and should) read more control structures in php in php documentation.
oh, , way. looks using codeigniter. did know can use site_url
function instead of prepending stuff base_url()
? you'd write url of link (although think have syntax error in part of code above):
<a href="<?=site_url("page/sales/viewsale/$sale")?>">
Comments
Post a Comment