devlog101010 devlog101010 - 2 years ago 91
HTML Question

Hide div if database contains value

I want to check if a MySQL database contains a specific value. If it is true I want to hide a HTML

. Is this possible?

Can I hide elements with PHP, or what should I use to hide the div? Thanks!

Answer Source

Try something like this in your PHP file. I have included an example of an item that is always rendered, and something that is conditionally rendered.

<div id="userinfo">
    <?php // This is always rendered by the server ?>
    Username: <?php htmlentities($row['username']) ?>

    <?php // This is rendered by the server if the column is true ?>
    <?php if ($row['admin']): ?>
        <div class="admin">(admin)</div>
    <?php endif ?>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download