Hi,
I have a database containing news and event, php echo’s the data ok within a div tag,
What I am trying to do is have php echo the data along with the div tag only if there is data in the database to display, if not the div tag is not echoed?
Any ideas? here is my source:
Thank you for any help or suggestions.HTML Code:<!-- only display this div if data is true --> <div class="divright"> <h2>What's comming up?</h2> <div class="rightcontent"> <?php // display from database "events" records $query="SELECT *, DATE_FORMAT(date, '%d-%m-%Y') as date FROM `events` ORDER BY date DESC "; // query string stored in a variable decending (DESC) $rt=mysql_query($query); // query executed echo mysql_error(); // if any error is there that will be printed to the screen while($nt=mysql_fetch_array($rt)){ echo "<h1>$nt[date]</h1> <h2>$nt[title]</h2> <p>$nt[event]</p>"; // name class and tag will be printed } ?> </div>



Reply With Quote

Bookmarks