Solved

Display Two Columns Per Row - Then Start a New Row

Posted on 2007-04-03
3
209 Views
Last Modified: 2012-05-05
Can someone take a quick look and see what I'm missing or why this isn't working the way I want it to?  I want to have two columns displayed per row and then start a new row.  Here's my code snippet:

//Query is here.

?>
  <table style="width: 80%; text-align: left; margin-left: 25%; margin-right: auto;" border="0" >
<?
while ($myfieldarray = mysql_fetch_assoc($query)) {
      if ( (intval($myfieldarray['id']) % 2) == 0 ) {
      ?>  <?
      } else {
      ?>
       <tr>
      <? } ?>
            <td align="right" width="325">
            <label><?=$myfieldarray['cTradeName']?></label>
            </td>
            <td align="left">
            <input type="checkbox" name="chkbox<?=$myfieldarray['id']?>" id="<?=$myfieldarray['id']?>" <?php isItChecked($myfieldarray['id'], $UserRecid) ?> >
            </td>
      <?
    if ( (intval($myfieldarray['id']) % 2) == 0 ) {
      ?>  <?
      } else {
      ?> </tr> <?
      }
} ?>
   </table>
0
Comment
Question by:Quetysis
3 Comments
 
LVL 29

Accepted Solution

by:
TeRReF earned 500 total points
ID: 18845065
I think it should be something like:

  <table style="width: 80%; text-align: left; margin-left: 25%; margin-right: auto;" border="0" >
<?
while ($myfieldarray = mysql_fetch_assoc($query)) {
      if ( (intval($myfieldarray['id']) % 2) != 0 ) {
      ?>
       <tr>
      <? } ?>
            <td align="right" width="325">
            <label><?=$myfieldarray['cTradeName']?></label>
            </td>
            <td align="left">
            <input type="checkbox" name="chkbox<?=$myfieldarray['id']?>" id="<?=$myfieldarray['id']?>" <?php isItChecked($myfieldarray['id'], $UserRecid) ?> >
            </td>
      <?
    if ( (intval($myfieldarray['id']) % 2) == 0 ) {
      ?> </tr> <?
      }
} ?>
   </table>

0
 

Author Comment

by:Quetysis
ID: 18845156
Thanks!  That did it!
0
 
LVL 49

Expert Comment

by:Roonaan
ID: 18845605
@TeRReF,

Did you receive my email?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now