douhe4608 2015-01-21 20:15
浏览 41
已采纳

如何在3 td表中显示数据循环

i want to create looping data in 3 td table

i want looping like this image

enter image description here

This is my code

<table>
<tr>
          <?php $sql="select * from study";
                        $rs=mysql_query($sql);
                        while($row1=mysql_fetch_array($rs)){ ?>
            <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>

                <td width="30%" align="left" valign="top"><input type="checkbox" name="minat" value="<?php echo $row1['studyid']; ?>" />
                  <?php echo $row1['studyname']; ?></td>

                <td width="30%" align="left" valign="top"><input type="checkbox" name="minat" value="<?php echo $row1['studyid']; ?>" />
                  <?php echo $row1['studyname']; ?></td>

                <td width="30%" align="left" valign="top"><input type="checkbox" name="minat" value="<?php echo $row1['studyid']; ?>" />
                  <?php echo $row1['studyname']; ?></td>
              </tr>
                    <?php } ?>

                      </table>

Help Me Thank's you all

  • 写回答

2条回答 默认 最新

  • drfkl66684 2015-01-21 20:27
    关注

    In your loop, check if it should add a tr beginning or end.

    This is just a sample code:

    <?php $sql = "select * from study";
    $rs = mysql_query($sql);
    $i = 0;
    echo "<table>";
    while($row = mysql_fetch_array($rs)){
        if($i%3 == 0) echo "<tr>";
        echo "<td><input type="checkbox">$row[studyname]</td>";
        if($i%3 == 2) echo "</tr>";
        $i ++;
    }
    echo "</table>";
    

    Actually, if you use div it will be very easy.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 51寻迹小车定点寻迹
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站
  • ¥15 滑块验证码移动速度不一致问题
  • ¥15 Utunbu中vscode下cern root工作台中写的程序root的头文件无法包含
  • ¥15 麒麟V10桌面版SP1如何配置bonding