vendredi 17 février 2017

php if/else statement in while loop

I'm having no luck with properly doing this if/else statement under the while loop I have setup.

Essentially, the if/else statement is checking a usergroup (type in this case) whether if admin/staff and the else for the base user group.

The admin/staff type should display buttons to edit/delete messages in the chat. But when logged in as an admin/staff they do not show up.

This is what should happen only for base users, but this happens to all groups:

With if/else code in the while loop and logged into any usergroup

This is whats supposed to happen when logged in as admin/staff:

Without the if/else code in the while loop and logged into any usergroup

The loop code:

while($extract = mysqli_fetch_array($result1)) {
    if($row['type'] == 'admin' or $row['type'] == 'staff') {
        echo "<div class='block block-rounded block-transparent push-15 push-50-r'>
            <div class='block-content block-content-full block-content-mini bg-gray-light'>
            <a class='font-w600' href='javascript:void(0)' target='_blank'>" . $extract['username'] . "</a> &nbsp; <span style='color:#D8D8D8; font-size:12px;' name='timestamp'>" . $extract['time_only'] . "</span>
            <br>
            <span style='color:grey;' class = 'msg'>" . $extract['msg'] . "</span> <span style='float:right;'><button class='btn btn-xs btn-default' type='submit' data-toggle='tooltip' title='Edit Message'><i class='fa fa-pencil'></i></button><button class='btn btn-xs btn-default' type='button' data-toggle='tooltip' title='Remove Message' name='dltmem'><i class='fa fa-times'></i></button></span>
            </div></div>";
    }
    else {
        echo "<div class='block block-rounded block-transparent push-15 push-50-r'>
            <div class='block-content block-content-full block-content-mini bg-gray-light'>
            <a class='font-w600' href='javascript:void(0)' target='_blank'>" . $extract['username'] . "</a> &nbsp; <span style='color:#D8D8D8; font-size:12px;' name='timestamp'>" . $extract['time_only'] . "</span>
            <br>
            <span style='color:grey;' class = 'msg'>" . $extract['msg'] . "</span>
            </div></div>";
    }
}

Aucun commentaire:

Enregistrer un commentaire