Search code examples
phpmysqlcodeigniter-3

If row status is 1 show the approved status in the table


I want to output statement you are approve if the row status = 1, the data can be output now i just want the statement saying approve.

here's my code

<div class="row">
    <div class="col-md-12">
        <table class="table table-striped">
            <tr>
                <th>Nominee Name</th>
                <th>Year</th>
                <th>Department</th>
                <th>StudentID</th>
                <th>Position</th>
                <th>View File</th>
                <th>Nominee Photo</th>
                <th>Nominated by</th>
                <th>status</th>
            </tr>
            <?php
            foreach ($nominees as $noms) {
                ?>
                <tr>
                    <td><?php echo $noms['name']; ?></td>
                    <td><?php echo $noms['year']; ?></td>
                    <td><?php echo $noms['department']; ?></td>
                    <td><?php echo $noms['studentid']; ?></td>
                    <td><?php echo $noms['position']; ?></td>
                    <td><a href="<?php echo base_url(); ?>uploads/<?php echo $noms['pdf']; ?>"></a></td>
                    <td><img src="<?php echo base_url(); ?>uploads/<?php echo $noms['photo']; ?>" style='width:50px;height:50px;'></td>
                    <td><?php echo $noms['nomname']; ?></td>
                    <?php if ($noms['approve'] == 1) { ?>
                        <td>Approve</td>
                    <?php } else { ?>
                        <td>pending</td>
                    <?php } ?>

                </tr>

            <?php } ?>
        </table>
    </div>
</div>

Solution

  • If the $nominees array returns the stays, then you can do like this

    <?php if ( $nom['status'] == 1) { ?>
                                <td>Approve</td>
                           <?php }else{ ?>
                           <td>pending</td>
                            <?php }?>