【问题标题】:Automatically creating div's using data from a sql table使用 sql 表中的数据自动创建 div
【发布时间】:2012-08-20 22:03:40
【问题描述】:

我正在尝试创建重复的divs,其中每个数据都从 SQL 数据库获得。我有创建divs 并使用正确数据填充正确字段的代码,但我的代码将divs 相互嵌套。

<?php
$query = mysql_query("SELECT id, name, location, amountRequested FROM     fundable");

while ($temp = mysql_fetch_array($query)) {
echo "<div class='widgetLoan'>";
echo "<div class='title'><h6>".$temp['name']."</h6><span class='widgetLoanCat'>Category</span>";
echo "<div class='num'><a href='#' class='blueNum'>".$temp['amountRequested']."</a></div>";
echo "</div>";
}
?>

【问题讨论】:

  • 你没有关闭“title” div

标签: php sql html


【解决方案1】:

试试这个:

<?php
$query = mysql_query("SELECT id, name, location, amountRequested FROM     fundable");

while ($temp = mysql_fetch_array($query)) {
echo "<div class='widgetLoan'>";
echo "<div class='title'><h6>".$temp['name']."</h6><span class='widgetLoanCat'>Category</span></div>";
echo "<div class='num'><a href='#' class='blueNum'>".$temp['amountRequested']."</a></div>";
echo "</div>";
}
?>

【讨论】:

  • 你不知道我盯着这个看了多久,谢谢你的帮助!
【解决方案2】:

你忘了关闭&lt;/div&gt;标签

改变

echo "<div class='title'><h6>".$temp['name']."</h6><span class='widgetLoanCat'>Category</span>";

echo "<div class='title'><h6>".$temp['name']."</h6><span class='widgetLoanCat'>Category</span></div>";

【讨论】:

  • 你不知道我盯着这个看了多久,谢谢你的帮助!
【解决方案3】:

您好像错过了我的 &lt;/div&gt; 标签。

【讨论】:

    猜你喜欢
    • 2017-08-08
    • 1970-01-01
    • 2021-11-08
    • 1970-01-01
    • 2014-02-05
    • 2023-03-20
    • 1970-01-01
    • 2020-09-28
    • 1970-01-01
    相关资源
    最近更新 更多