Tayler Hughes
Tayler Hughes

Reputation: 41

Automatically creating div's using data from a sql table

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

Upvotes: 1

Views: 3046

Answers (3)

Mike M
Mike M

Reputation: 212

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

Upvotes: 0

Gabriel Sosa
Gabriel Sosa

Reputation: 7956

you forgot to close a </div> tag

change

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

for

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

Upvotes: 1

RedhopIT
RedhopIT

Reputation: 619

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

Upvotes: 3

Related Questions