本帖最后由 lazygc520 于 2011-09-22 13:13:10 编辑

解决方案 »

  1.   

    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
       <?php
    $i = 0;
         foreach($row1 as $k=>$v)
         {
     
    ?>
        <td><?php echo '<img src="test.php?codebar=BCGcode39extended&text='.$v.'">';?></td>
        <?php
    if($i%2 == 0){echo '</tr><tr>';}
    $i ++;
    }
    ?>
      </tr>
    </table>
      

  2.   

     请把td的样式提到css文件中:      <?php
                $k=0; 
                foreach($row1 as $k=>$v)
                {   if($k%2==0)
                      echo '<tr><td ><img src="test.php?codebar=BCGcode39extended&text='.$v.'"></td>';
                    else
                      echo '<td><img src="test.php?codebar=BCGcode39extended&text='.$v.'"></td></tr>';
                    $k++;            
    }
            ?>
      

  3.   

    修改后的格式: <?php
       $k=0;  
       foreach($row1 as $k=>$v)
       { 
    if($k%2 == 0)
    {
    echo '<td colspan="3" rowspan="2" style="text-align: center; color: windowtext; font-size: 12.0pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: 宋体; vertical-align: bottom; white-space: nowrap; border-left: .5pt solid windowtext; border-right: medium none; border-top: .5pt solid windowtext; border-bottom: .5pt solid black; padding: 0px">
    <img src="test.php?codebar=BCGcode39extended&text='.$v.'"></td>';
    }
    else
    {
    echo '<td rowspan="2" style="text-align: center; color: windowtext; font-size: 12.0pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: 宋体; vertical-align: bottom; white-space: nowrap; border-left: medium none; border-right: .5pt solid windowtext; border-top: medium none; border-bottom: .5pt solid black; padding: 0px">
    <img src="test.php?codebar=BCGcode39extended&text='.$v.'"></td>';
    }
     $k++;   
    }
    ?>
    现在的情况是3个条形码还在一排(同一个TR中),请问怎么解决?
      

  4.   


    你没有echo <tr></tr>这样的语句。。  <?php
      $k=0; 
      foreach($row1 as $k=>$v)
      { if($k%2==0 && $k!=end($row1))
          echo '<tr><td ><img src="test.php?codebar=BCGcode39extended&text='.$v.'"></td>';
        else if($k%2==0 && $v==end($row1))
          echo '<tr><td><img src="test.php?codebar=BCGcode39extended&text='.$v.'"></td></tr>';
        else
          echo '<td><img src="test.php?codebar=BCGcode39extended&text='.$v.'"></td></tr>';
      $k++;  
    }
      ?>
      

  5.   

     <?php
      $k=0; 
      foreach($row1 as $k=>$v)
      { if($k%2==0 && $v!=end($row1))
          echo '<tr><td ><img src="test.php?codebar=BCGcode39extended&text='.$v.'"></td>';
        else if($k%2==0 && $v==end($row1))
          echo '<tr><td><img src="test.php?codebar=BCGcode39extended&text='.$v.'"></td></tr>';
        else
          echo '<td><img src="test.php?codebar=BCGcode39extended&text='.$v.'"></td></tr>';
      $k++;  
    }
      ?>
      

  6.   

    问题是这里只有两个TD,在同一个TR中。形式如下。这样能实现吗?
      

  7.   

    整个tr的内容如下:<tr height="26" style="height: 20.1pt">
    <td height="26" style="height: 20.1pt; color: windowtext; font-size: 12.0pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: 宋体; text-align: general; vertical-align: bottom; white-space: nowrap; border-left: .5pt solid windowtext; border-right: medium none; border-top: medium none; border-bottom: medium none; padding: 0px">
     </td>
    <td colspan="3" rowspan="2" style="text-align: center; color: windowtext; font-size: 12.0pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: 宋体; vertical-align: bottom; white-space: nowrap; border-left: .5pt solid windowtext; border-right: .5pt solid black; border-top: .5pt solid windowtext; border-bottom: .5pt solid black; padding: 0px">
    <img src="test.php?codebar=BCGcode39extended&text=<?php echo $row['0']; ?>"></td>
    <?php
       $k=0;  
       foreach($row1 as $k=>$v)
       { 
    if($k%2 == 0)
    {
    echo '<td colspan="3" rowspan="2" style="text-align: center; color: windowtext; font-size: 12.0pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: 宋体; vertical-align: bottom; white-space: nowrap; border-left: .5pt solid windowtext; border-right: medium none; border-top: .5pt solid windowtext; border-bottom: .5pt solid black; padding: 0px">
    <img src="test.php?codebar=BCGcode39extended&text='.$v.'"></td>';
    }
    else
    {
    echo '<td rowspan="2" style="text-align: center; color: windowtext; font-size: 12.0pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: 宋体; vertical-align: bottom; white-space: nowrap; border-left: medium none; border-right: .5pt solid windowtext; border-top: medium none; border-bottom: .5pt solid black; padding: 0px">
    <img src="test.php?codebar=BCGcode39extended&text='.$v.'"></td>';
    }
     $k++;   
    }
    ?>
    <td style="color: windowtext; font-size: 12.0pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: 宋体; text-align: general; vertical-align: bottom; white-space: nowrap; border-left: medium none; border-right: .5pt solid windowtext; border-top: medium none; border-bottom: medium none; padding: 0px">
     </td>
    <td style="color: windowtext; font-size: 12.0pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: 宋体; text-align: general; vertical-align: bottom; white-space: nowrap; border: medium none; padding: 0px"> </td>
    </tr>
      

  8.   

    我已经调好了。感谢大家给我的思路。<tr height="26" style="height: 20.1pt">
    <td height="26" style="height: 20.1pt; color: windowtext; font-size: 12.0pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: 宋体; text-align: general; vertical-align: bottom; white-space: nowrap; border-left: .5pt solid windowtext; border-right: medium none; border-top: medium none; border-bottom: medium none; padding: 0px">
     </td>
    <td colspan="3" rowspan="2" style="text-align: center; color: windowtext; font-size: 12.0pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: 宋体; vertical-align: bottom; white-space: nowrap; border-left: .5pt solid windowtext; border-right: .5pt solid black; border-top: .5pt solid windowtext; border-bottom: .5pt solid black; padding: 0px">
    <img src="test.php?codebar=BCGcode39extended&text=<?php echo $row['0']; ?>"></td>
    <td colspan="3" rowspan="2" style="text-align: center; color: windowtext; font-size: 12.0pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: 宋体; vertical-align: bottom; white-space: nowrap; border-left: .5pt solid windowtext; border-right: .5pt solid black; border-top: .5pt solid windowtext; border-bottom: .5pt solid black; padding: 0px">
    <?php
    foreach($row1 as $k=>$v)
    {
    if($k%2==0)
    echo '<img src="test.php?codebar=BCGcode39extended&text='.$v.'">&nbsp;&nbsp;&nbsp;';
    else
    echo '<img src="test.php?codebar=BCGcode39extended&text='.$v.'"><br />';
    $k++;
    }
    ?></td>
    <td style="color: windowtext; font-size: 12.0pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: 宋体; text-align: general; vertical-align: bottom; white-space: nowrap; border-left: medium none; border-right: .5pt solid windowtext; border-top: medium none; border-bottom: medium none; padding: 0px">
     </td>
    <td style="color: windowtext; font-size: 12.0pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: 宋体; text-align: general; vertical-align: bottom; white-space: nowrap; border: medium none; padding: 0px">
     </td>
    </tr>
      

  9.   


    这样也可以,只是,判断的时候不直接echo,而是连接到不同的串里边。然后再echo连接好的串。