/    Sign up×
Community /Pin to ProfileBookmark

alternate Row Problem

Hi The below code is supposed to display tables side by side so to per row, It’s kind of working until it gets to the last entry. In my sample query The divs are

  • 1. left

  • 2. right
    3.left

  • 4. left
  • nuber 4 should be right.

    Any ideas why its not working

    [code]
    $i = 0
    $col = ($i % 2) ? ‘right’ : ‘left’;
    echo “<div class=”$col”>”;?>

    <table class=”table” style=”width:99%;”>
    <tr>
    <td rowspan=”3″ style=”width:20%;” valign=”top”>
    <a href=”albumPhotos.php?photos=<?php echo $album[‘album’];?>&amp;bid=<?php echo $buddy_id; ?>”><img src=”../user_images/<?php echo $album[‘album_cover’]; ?>” width=”<?php echo $newwidth; ?>” height=”<?php echo $newheight; ?>” alt=”<?php echo $album[‘album_cover’]; ?>” /></a>
    </td>
    <td style=”width:30%;” class=”eventSub”>Album:</td>
    <td valign=”top”><?php echo $album[‘album’]; ?></td>
    </tr>
    <tr>
    <td style=”width:25%;” class=”eventSub”>Owner:</td>
    <td><a title=”Go to members profile” class=”linkText” href=”../profile.php?=id=<?php echo $album[‘user_id’]; ?>”><?php echo $buddy_info[‘first_name’].’ ‘.$buddy_info[‘last_name’];?></a></td>
    </tr>
    <tr>
    <td style=”width:25%;” class=”eventSub”>Created:</td>
    <td><?php echo $album[‘createdate’]; ?></td>
    </tr>
    </table>

    <? echo “</div>”;
    $i++;
    } ?>

    <?php }

    }?>
    [/code]

    to post a comment
    PHP

    1 Comments(s)

    Copy linkTweet thisAlerts:
    @gomisuteMar 10.2008 — replace this
    [CODE]
    <?
    $col = ($i % 2) ? 'right' : 'left';
    echo "<div class="$col">";
    ?>
    [/CODE]

    with this:

    [code=php]
    <?
    $col = ($i % 2) ? '<div style="float:left;">' : '<div style="float:right; clear:both">';
    ?>

    <?= $col ?>
    [/code]
    ×

    Success!

    Help @kproc spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.18,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...