WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] div format

[Resolved] div format

  • Having problem with my div format

    This code is working and…

    <?php
    $last_band = null;
    foreach ( $bandinfo as $infoband ) : ?>
    
        <?php if ($last_band != $infoband['band1']): ?>
            <h3><?php echo $infoband['band1']; ?></h3>
        <?php endif; ?>
    
        <?php echo $infoband['lineup']; ?> <?php echo $infoband['year']; ?><br>
    
    <?php
        $last_band = $bandinfo['band1'];
    endforeach; ?>

    it gives me this result
    Band1
    lineup1 year1
    lineup2 year2
    lineup3 year3

    Band2
    lineup1 year1
    lineup2 year2
    lineup3 year3

    Now I want this format instead
    Band1
    <div>
    lineup1 year1
    lineup2 year2
    lineup3 year3
    </div>

    Band2
    <div>
    lineup1 year1
    lineup2 year2
    lineup3 year3
    </div>

    and have tried this code but only get errors like
    Parse error: syntax error, unexpected T_AS in …

    <?php
    $max = count($bandinfo);
    for ( $i = 0; $i < $max; $i++) $bandinfo as $infoband ) :
        $infoband = $bandinfo[$i];
    ?>
    
        <?php if ($i == 0 || $bandinfo[$i-1]['band1'] != $infoband['band1']): ?>
            <h3><?php echo $infoband['band1']; ?></h3>
            <div class="bandinfo">
        <?php endif; ?>
    
        <?php echo $infoband['lineup']; ?> <?php echo $infoband['year']; ?><br>
    
    <?php
         <?php if ($i == $max-1 || $bandinfo[$i+1]['band1'] != $infoband['band1']): ?>
            </div>
        <?php endif; ?>
    endforeach; ?>

    Have anyone some suggestion?

Viewing 15 replies - 1 through 15 (of 26 total)
Viewing 15 replies - 1 through 15 (of 26 total)
  • The topic ‘[Resolved] div format’ is closed to new replies.