1

我正在尝试div在从 SQL 数据库中获得的每个数据中创建具有不同数据的重复 s。我有代码创建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>";
}
?>
4

3 回答 3

3

尝试这个 :

<?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>";
}
?>
于 2012-08-25T18:41:48.640 回答
1

你忘了关闭</div>标签

改变

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>";
于 2012-08-25T18:41:53.447 回答
0

Looks like you are missing a </div> tag to me.

于 2012-08-25T18:44:07.977 回答