View Full Version : How do I quote html on my php page ?

09-02-2009, 04:51 PM

I am building my page with PHP and on one of my pages I need to
show some html code that can be copy and pasted by the client.

For example, this is my code:

while ($row_prod = mysql_fetch_assoc($result_prod)) {
$D_name = "{$row_prod['prod_name']}";
$D_code = "{$row_prod['code']}";
$D_id = "SF649"."{$row_prod['prod_id']}";
echo "<tr><td width = \"140px\">$D_name</td></td><td width = \"400px\">

<!-- //SF-Code--$D_name--$D_code--// -->
<a href=\"http://www.my-site.com/check.php?key=$D_id\"
onclick=\"NewWindow(this.href,'','800','600','yes','default'); return false\"
onfocus=\"this.blur()\" >
<img src=\"http://www.my-site.com/image_load.php?id=$sup_id\"
alt=\"Click to Verify - Before you Buy\"
border=\"0\" >

} // end while

Now all the code that is between the bold tags is for copying and pasting.

The problem is that if I just place it as it is, I get a clickable image
which is what the client should have on his website.

How do I de-activate this code so I just get the code showing ?


09-02-2009, 06:02 PM
You need to escape the html coding. Use &lt; and &gt; to escape the < and > and that should pretty much do it.

09-02-2009, 07:54 PM

That worked out fine :thumbsup: