0

I have a page on my testing site where users can post news. The posting page has a title, link, and body. The link can be left optional. I wanted the page to turn out that if a link was provided, it would make an <a> tag around the title, but if no link was provided, it would simply display the title. This is how I tried to do that.

//query the db
$getnews = mysql_query("SELECT * FROM news ORDER BY $order") or die(mysql_query());

while ($row = mysql_fetch_assoc($getnews))
{

//get data
$id = $row['id'];
$title = $row['title'];
$link = $row['link'];
$body = $row['body'];
$date = $row['date'];
$rating = $row['rating'];
$poster = $row['poster'];


echo "<a href='rate.php?id=$id'>&oplus;</a> <b>($rating) ";

if ($link="nolink") {
    echo $title;
} else {
    echo "<a href='$link' target='_blank'>$title</a>";
}

echo "</b> by $poster<br>
<font size='2'>($date)</font>
";

echo nl2br($body);

echo "<hr>";

}

It didn't work and I can see why, but I do not know what method I should be using.

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by atalkingfish
0

By golly, that worked! I can't believe I didn't think of that. Thank you very much!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.