I store my testimonials in a database table and would like them to be displayed on my website via this for loop:
<?php
$count = mysql_fetch_assoc(mysql_query("SELECT COUNT(*) cnt FROM testimonials"));
for ($i = 1; $i <= intval($count['cnt']); $i++)
{
$sql = mysql_query("SELECT * FROM testimonials WHERE id='{$i}'");
?>
<li class="span4">
<div class="thumbnail thumbnail-1">
<section>
<a class="link-1" style="cursor:pointer;"><?php echo $sql['name'] ?></a>
<p><?php echo $sql['text'] ?></p>
<a href="http:// <?php echo $sql['product'] ?> /" class="link-1"><?php echo $sql['product'] ?></a>
</section>
</div>
</li>
<?php
}
?>
The issue is that the $sql variables product, name and text are not displaying. However the $count is getting the correct intval, so it knows there are entries.
It's also worth pointing out that the loop is working as I get the <li> <div> and <section> tags working, the only issue is the <a>'s and the <p> not getting the textual value from the echo
P.S. I know that mysql_* functions are depreciated however my php version 5.3 and they are only depreciated from 5.5 so they are ok for my website.