Solved

Display Two Columns Per Row - Then Start a New Row

Posted on 2007-04-03
3
219 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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 …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

914 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

19 Experts available now in Live!

Get 1:1 Help Now