using HTML with PHP

Permabanned
Joined
22 Apr 2007
Posts
1,805
Hi,

In this piece of code how do I use <h3> tags around the echo($obj->p_title .

Code:
//List of news - but truncated to 50 chars.
	$qry = mysql_query("SELECT * FROM news ORDER BY id DESC");
	while ($obj = mysql_fetch_object($qry))
	{
		echo($obj->p_title . " " . $obj->p_summary . " <a href=\"news.php?id=$obj->id\">(full story here)</a><br />");

Basically, I want p_title to adopt my CSS formatting for an <h3> component
 
Code:
echo "<h3>$obj->p_title $obj->p_summary <a href='news.php?id=$obj->id'>(full story here)</a><br /></h3>";

(You can use variables in double-quoted strings without having to drop out of the string literal; you can use single quotes in HTML, so always use the opposite of what you're using in your string literal so you don't have backslashes everywhere; `echo` is not a normal function and is typically called without parentheses, the same as things like `include` and `print`.)
 
Back
Top Bottom