jeudi 28 juillet 2016

Delete some UL if empty

right now my output is something like this enter image description here

I want to delete the list that are empty

just tried this code empty or isset inside the listitems

<?php if(isset($page<1): //but i got an error instead    ?>

even something like

<?php if(empty($page): //but i got different output    ?>

heres my running code without if statement

<?php 
$letter='A';
for($i= 1; $i <=26 ;$i++,$letter++):?>
<?php 

    $pages = $db->prepare("
    SELECT * FROM pages WHERE LEFT(`title`, 1) = '".$letter."'

    ");
    //$check =$db->query("SELECT * FROM watch WHERE animelist_id=".$page['id']." and acc_id=".$_SESSION["user_id"]."");
    $pages->bindParam(1,$letter, PDO::PARAM_STR);
    $pages->execute();
?>

<div class = "listitems">

    <?php echo '<h5>'.$letter.'</h5>';?>
            <?php foreach($pages as $page): ?>

                        <ul>
                            <li>
                            <a href="<?php echo BASE_URL;?>/page.php?page=<?php echo e($page['slug']);?>"><?php echo e($page['label']);?></a>

                            </li>
                        </ul>



            <?php endforeach; ?>

</div>
<?php endfor; ?>

Aucun commentaire:

Enregistrer un commentaire