Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Display Two Columns Per Row - Then Start a New Row

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

856 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