I want to fetch data from my MySQL and echo it out only if $featured == 1
.
It works, the only one with $featured == 1
will show title, but my problem is that it also makes posts from everything else in my database (empty posts). I only want it to show the posts with == 1 and nothing more nothing less. I can't manage to fix it.
<aside id="featured" class="body"><article>
<?php
for ($i=0; $i <$num_results; $i++){
$row1 = $result1->fetch_assoc();
$featured = ($row1['featured']);
if ($featured == 1) {
echo $row1['title'];
} else {
}
?>
<figure>
<img src="images/black2.gif" alt="Black 2" style="width: 300px;"/>
</figure>
<hgroup>
<h2>Featured Article</h2>
<h3><a href="goodies/black2.html">
</a></h3>
</hgroup>
<p> </p>
<footer class="post-info">
<abbr class="published" title="date">20 juli 2012</abbr>
<address class="vcard author">By<a class="url fn" href="portfolio.html">F4LLCON</a>
</address></footer><!-- /.post-info -->
</article>
<?php
}
$result1->free();
?>
</aside><!-- /#featured -->
- Will look like:
- But I want it like this: