使用 sql 表中的数据自动创建 div [英] Automatically creating div's using data from a sql table

查看:27
本文介绍了使用 sql 表中的数据自动创建 div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

";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>";}?>

解决方案

试试这个:

";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>";}?>

I'm trying to create duplicate divs with different data in each obtained from a SQL database. I have the code creating the divs and populating the correct fields with the correct data, but my code is nesting the divs within each other.

<?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>";
}
?>

解决方案

Try this :

<?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>";
}
?>

这篇关于使用 sql 表中的数据自动创建 div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆