Show Hide div if, if statement is true

Christian picture Christian · Aug 11, 2011 · Viewed 188.2k times · Source

My code works to a point. What I want is that when this if statement is false, the <div> doesn't show

<?php
    $query3 = mysql_query($query3);
    $numrows = mysql_num_rows($query3);
    if ($numrows > 0) {
        $fvisit = mysql_fetch_array($result3);
    }
    else {
    }
?>

Answer

munjal picture munjal · Aug 11, 2011

You can use css or js for hiding a div. In else statement you can write it as:

else{
?>
<style type="text/css">#divId{
display:none;
}</style>
<?php
}

Or in jQuery

else{
?>
<script type="text/javascript">$('#divId').hide()</script>
<?php
}

Or in javascript

else{
?>
<script type="text/javascript">document.getElementById('divId').style.display = 'none';</script>
<?php
}