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

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -