i'm using php/mysql with smarty (php template generator). I'm looping through an sql query and getting the data to display on the .tpl file.
$query = "SELECT * from recipes";
$result = mysqli_query($db_server, $query);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
// assign user information to template
$tpl->assign('title', $row['title']);
$tpl->assign('submission_date', $row['submission_date']);
$tpl->assign('instructions', $row['instructions']);
$tpl->assign('category', $row['category']);
}
} else {
echo "0 results";
}
my html:
<div class="content">
{if $signedin}
<h4>{$title}<h4>
<h6>{$submission_date}</h6>
<p>{$instructions}</p>
<p>{$category}</p>
{else}
You are currently not signed in.
{/if}
</div>
The problem is that this is only displaying the most recent entry and i'm trying to display every entry in the database.
What's wrong with my loop?
I have placed echo in between each $tpl->assign, and it loops and displays all data, so i'm wondering if this is a Smarty issue.