Help with PHP/MySQL if else statement that effects the html?

misdanzigfits

New member
I am trying to figure out how to write an if else statement. What I need it to do if check if the image row is empty and if so then to echo out this html. If the $image has a value then generate this html.

Here is a snippet of my code (without the if else statement):
<?php

$sql = "SELECT * FROM ggNews";
$result = mysql_query($sql);

while($row = mysql_fetch_assoc($result)) {
$id = $row["id"];
$title = $row["title"];
$month = $row["month"];
$day = $row["day"];
$year = $row["year"];
$image = $row["image"];
$link = $row["link"];
$link_name = $row["link_name"];
$content = $row["content"];

echo "<div class=\"border\">";
echo "<h2>$title Â*Â*<span class=\"small subtle\">$month/$day/$year</span></h2>";
echo "<span class=\"float_left\"><img src=\"uploads/$image\" alt=\"$image\" /></span>";
echo "<p>$content</p>";
echo "<p class=\"link\"><a href='$link'>$link_name</a></p>";
echo "<div class=\"clear\"></div>";
echo "</div><!-- end border -->";
}
?>

Any help is much appreciated.
 
Back
Top