php - If statement to not show div / h2 -
this each / if statement displays changes, , right below it displays changes made.
i trying write if statement tells not show h2 , #change_box if there no changes.
help appreciated.
<h2 class="changes"> changes: </h2> <div id="change_box"> <? foreach ($audit['events'] $event):?> <?if ( $event['type'] != 'comment'):?> <span class="field"> <?= $event['field']?> </span>: <?= $event['value'] ?> <?=($event['previous'])?> <?endif?> <?endforeach?> </div>
<?php if ($changes) { // you'll have set variable //echo of html else { //echo stuff you'd rather show if didn't change } ?>
to give idea of how i'd write code
<?php if ($changes) { echo '<h2 class="changes">changes:</h2>'; echo '<div id="change_box">'; foreach ($audit['events'] $event) { if ($event['type'] != 'comment') { echo $event['field'] . </span> . $event['value'] . $event['previous']; } } echo "</div>" } ?>
Comments
Post a Comment