http://expert.csdn.net/Expert/topic/1329/1329722.xml?temp=.5767176

解决方案 »

  1.   

    $result =mysql_query("select * from cp");
    while( $rows=mysql_fetch_array($result) )
      if ( $i % 2 == 1 ) print $rows[test]."&nbsp;<br>";
      else print $rows[test]."&nbsp;";
    }
      

  2.   

    <?
    $i=1;
    ...
    while ($row=mysql_fetch_object(...))
    {
    if ($i mod 2==1) 
    {
    echo $row->列名;
    $i=$i+1;
    }
    if ($i mod 2==0) 
    {
    echo $row->列名."<br>";
    $i=$i+1;
    }
    //用表格显示同样的道理。
    //你试一下行不行
    }?>
      

  3.   

    不行啊,我着上面的方法做了,不行啊
      <?
    $i=1;
    $con=mysql_connect("localhost","root","root");
    $db=mysql_select_db("dzsw1",$con);
    $sql = "select *  FROM cp_dl";
    $result = mysql_query($sql,$con);
    while ($r= mysql_fetch_array($result))
    {
    if ($i % 2==1) 
    {
    echo $r[lbmc];
    $i=$i+1;
    }
    if ($i % 2==0) 
    {
    echo $r[lbmc]."<br>";
    $i=$i+1;
    }
    }
    ?>
    显示是这样的
     外衣外套   
     大衣风衣  
     内衣睡衣   
     羽绒服装  
     皮革服装   
     民族服装  
     休闲服装   
     运动服装  
    可是我要的是这样的结果
     外衣外套   大衣风衣  
     内衣睡衣   羽绒服装  
     皮革服装   民族服装  
     休闲服装   运动服装
      

  4.   

    <?
    $i=1;
    $con=mysql_connect("localhost","root","root");
    $db=mysql_select_db("dzsw1",$con);
    $sql = "select *  FROM cp_dl";
    $result = mysql_query($sql,$con);
    while ($r= mysql_fetch_array($result)){
    if ($i % 2==1) echo $r[lbmc];
    if ($i % 2==0) echo $r[lbmc]."<br>";
    $i=$i+1;
    }
    ?>
      

  5.   

    <?
    $i=1;
    $con=mysql_connect("localhost","root","root");
    $db=mysql_select_db("dzsw1",$con);
    $sql = "select *  FROM cp_dl";
    $result = mysql_query($sql,$con);
    while ($r= mysql_fetch_array($result)){
    if ($i % 2==1) echo $r[lbmc]."&nbsp;&nbsp;&nbsp;";
    if ($i % 2==0) echo $r[lbmc]."<br>";
    $i=$i+1;
    }
    ?>
      

  6.   

    <?
    $i=1;
    $count=4;//set this to change count of items display in a line
    $con=mysql_connect("localhost","root","root");
    $db=mysql_select_db("dzsw1",$con);
    $sql = "select *  FROM cp_dl";
    $result = mysql_query($sql,$con);
    while ($r= mysql_fetch_array($result)){
    if ($i % $count==1) echo $r[lbmc];
    if ($i % $count==0) echo $r[lbmc]."<br>";
    $i=$i+1;
    }
    ?>