【问题标题】:dynamic row creation php and html动态行创建 php 和 html
【发布时间】:2010-07-12 05:42:55
【问题描述】:

我想从 mysql 查询中创建一个表 表格应该显示在哪里

pic1       pic2     pic3
name1      name2    name3
-------------------------
pic4       pic5     pic6
name4      name5    name6

请说明如何使用 php 和 html 来实现?


好的,它将显示图片和对应的名称,picture1 将是与 pic2、pic3 等相同的图片,name1 是对应的名称,如 orkut 或 Facebook,我试过喜欢 代码;-

for ($i = 0; $i < 2; $i++) {
    ?>
    <tr>
        <? for ($j = 0; $j < 3; $j++) {
            ?>

            <td>
                <table>
                    <tr>
                        <td align="left" valign="top"><a href="#"><img src="images/speak-pic.jpg" width="88" height="88"
                                                                       border="0" class="pic-bod"/></a></td>
                    </tr>
                    <tr>
                        <td align="left" valign="top"><a href="#" class="link-ar"><? echo $t["profile_name"]?>  </a>
                        </td>
                    </tr>
                </table>
            </td>



        <?
        }
        ?>
    </tr>
<?
}

【问题讨论】:

  • 你开始的数据是什么;到目前为止,您尝试过什么吗?如果是这样,你到底卡在哪里了?
  • 现在,当你说它应该看起来像那样时,你是指一个真正的桌子,还是你的意思是像这样出来的纯文本?您的问题到底在哪里,PHP 还是 HTML?我们通常喜欢解决具体问题,而不是为某人完成整个任务。

标签: php mysql


【解决方案1】:

首先从查询中获取结果并循环它。

// first make the connection..., then
$sql = "SELECT xxxxxx";
$result = mysql_query($sql);
foreach($rs = mysql_fetch_assoc()) {
  // put the echo statement here with the apropriate html tags.
}

如果您想深入学习,请从 sitepoing.com 获取此链接 http://articles.sitepoint.com/article/php-gallery-system-minutes

【讨论】:

    猜你喜欢
    • 2012-04-06
    • 2011-03-14
    • 2011-05-20
    • 1970-01-01
    • 2012-05-05
    • 2013-10-20
    • 1970-01-01
    • 2017-04-03
    • 1970-01-01
    相关资源
    最近更新 更多