Question

I have 2 tables named authors & books. Authors must have a logo. I have to display this like author name , logo,then all the books of that author and so on. books table contain a field (show_logo), if the show_logo is 0 for all the books of that author then the logo will display at the begining (ie after author name) else logo will display after that book(show_logo 1). If the show_logo is 1 for any book then it will display properly after that book, Otherwise won't..am using the code below

<?php
if ($author) {
    foreach ($$author as $key => $val) {
?>
        <tr style="background-color: #58353C;"><?php
        if ($val['$author_image']) {
?>
            <td><img src="<?= base_url(); ?>uploads/<?= $author; ?>" style="width: 90px;height: 90px;"/></td>
            <td style="color: #F5E78F;" colspan="4"><b><?= $val['$author_name']; ?></td>
    <?
            foreach ($val['books'] as $key => $val1) {
    ?>
            <tr style="background-color:<?= $color ?>">
    <?php
                if ($val1['author_image']) {
    ?>
                    <td style="padding-left: 20px;color: black; "><img src="<?= base_url(); ?>uploads/<?= $val1['author_image']; ?>" style="width: 75px;height: 75px;" /></td>
    <?php } ?>
                <td style="color: black;"><?= $val1['author_title']; ?></td>
                <td width="150px" style="text-align: left;color: black;"><a class="more" style="color: black;font-size: 11px;" href="<?= site_url('author/author_view/' . $key); ?>" rel="facebox">More Details..</a></td>
    <?
                if ($val1['show_logo'] == '1') {
                    if ($val['author_logo']) {
    ?></tr>
                    <tr style="background-color:<?= $color; ?>" on>
                        <td colspan="5"><img src="<?= base_url(); ?>uploads/<?= $val['author_logo']; ?>" style="width: 998px;height: 175px;" /></td>
                    </tr>                                                                                                                                            
<?
                    }
                } else {
?></tr> <?
                }
                $counter++;
            }
        }
    }
}
?>
Was it helpful?

Solution

why don't you use the HTML Table Library that CodeIgniter 2.x includes in default package? Just pre-format you arrays to reach proper structure.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top