I kind of understand that you can do this:
<?php
$str = "A 'quote' is <b>bold</b>";
// Outputs: A 'quote' is <b>bold</b>
echo htmlentities($str);
// Outputs: A 'quote' is <b>bold</b>
echo htmlentities($str, ENT_QUOTES);
?>
Which gives me the right idea, but I don't understand how you do this for large sections of HTML that have the occasional variable or array in it.
This is what my PHP looks like at the moment:
<?php
$apartment = $_POST['apartment'];
foreach ($apartment as $value){
$select=$select.",\"".$value . "\"";
}
/* Remove Leading comma*/
$searchit=substr($select,1);
/*Show the selected fields*/
$db="proposalsdb";
$link = mysql_connect("localhost","root","******");
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());
$result=mysql_query("SELECT * FROM apartments WHERE apartment IN ($searchit)")
or die("SELECT Error: ".mysql_error());
$numrows=mysql_num_rows($result);
$row_result = mysql_fetch_assoc($result);
if ($numrows > 0)
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<STYLE>
* { MARGIN: 0cm 0cm 0pt; FONT-FAMILY: Trebuchet MS, Verdana}
ul {
list-style-type:circle; padding-left:30px;}
</STYLE>
<META content="MSHTML 6.00.2800.1476" name=GENERATOR></HEAD>
<BODY leftMargin=1 topMargin=1 rightMargin=1>
<DIV style="BORDER-RIGHT: #5781ae 1px solid; PADDING-RIGHT: 20px; BORDER-TOP: #5781ae 1px solid; PADDING-LEFT: 20px; FONT-WEIGHT: bold; BACKGROUND: #5781ae; PADDING-BOTTOM: 10px; BORDER-LEFT: #5781ae 1px solid; COLOR: #ffffff; PADDING-TOP: 10px; BORDER-BOTTOM: #5781ae 1px solid">
<DIV align=left><IMG height=48 src="http://www.servicedapartmentsbristol.com/worldlogo.gif" width=75 align=middle><FONT face="Arial, Helvetica, sans-serif" size=3> Feel at home wherever you travel...</FONT></DIV></DIV>
<DIV style="BORDER-RIGHT: #5781ae 1px solid; PADDING-RIGHT: 20px; PADDING-LEFT: 20px; FONT-WEIGHT: normal; BACKGROUND: #ffffff; PADDING-BOTTOM: 0px; BORDER-LEFT: #5781ae 1px solid; COLOR: #000000; PADDING-TOP: 0px">
<p style='font-size:12px'> </P>
<p style='font-size:12px'><BR>Dear <<&dear>> </P>
<p style='font-size:12px'> </P>
<P style="font-size:14px; "><STRONG>E-PROPOSAL for the supply of serviced apartment accommodation to <<&company>>.</STRONG></P>
<TABLE style='BORDER-RIGHT: #5781ae 1px solid; BORDER-TOP: 0px; BORDER-LEFT: #5781ae 1px solid; BORDER-BOTTOM: #5781ae 1px solid' cellSpacing=0 cellPadding=10 width='90%' align=center>
<? do { ?>
<TR bgColor=#000066>
<TH style='BORDER-RIGHT: 0px; BORDER-TOP: #5781ae 1px solid; FONT-SIZE: 14px; BORDER-LEFT: 0px; COLOR: #5781ae; BORDER-BOTTOM: #5781ae 1px solid; BACKGROUND-COLOR: #e6e1d2' scope=col colSpan=3>SACO SERVICED APARTMENTS -
<? echo $row_result['city']; ?>
</TH>
</TR>
<TR>
<TD colspan='2'>
<p style='font-size:12px'><A href='
<? echo $row_result['url']; ?>
'>
<? echo $row_result['apartment']; ?>
</A></P>
<P style='font-size:12px'>
<? echo $row_result['summary']; ?>
</P></TD>
<TD style='border-left:1px dotted #517dae' rowSpan=4><IMG src='<? echo $row_result['imgurl']; ?>' align=right></TD>
</TR>
<TR style='background-color:#EAF0F7' colspan='2' scope='col'>
<TD style='text-align:right; border-right:1px dotted #517dae; border-top:1px dotted #517dae' width='270' valign='top'>
<P align='left' style='font-size:12px' ><strong>Studio Apartment</strong></P></TD>
<TD style='border-top:1px dotted #517dae;' width='319' valign='top'><p style='font-size:12px'>£<? echo $row_result['rate1']; ?></p></TD>
</TR>
<TR colspan='2' scope='col'>
<TD style='text-align:right; border-right:1px dotted #517dae' valign='top'>
<P style='font-size:12px' align='left'><strong>One Bedroom Apartment</strong></P></TD>
<TD valign='top'><p style='font-size:12px'>£<? echo $row_result['rate2']; ?></p></TD>
</TR>
<TR style='background-color:#EAF0F7' colspan='2' scope='col'>
<TD style='text-align:right; border-right:1px dotted #517dae' valign='top'>
<P style='font-size:12px' align='left'><strong>Two Bedroom Apartment</strong></P></TD>
<TD valign='top'><p style='font-size:12px'>£<? echo $row_result['rate3']; ?></p></TD>
</TR>
<? } while ($row_result = mysql_fetch_assoc($result)); ?>
</table>
</DIV>
<DIV style="BORDER-RIGHT: #5781ae 1px solid; PADDING-RIGHT: 20px; BORDER-TOP: #5781ae 1px solid; PADDING-LEFT: 20px; FONT-WEIGHT: bold; BACKGROUND: #5781ae; PADDING-BOTTOM: 5px; BORDER-LEFT: #5781ae 1px solid; COLOR: #ffffff; PADDING-TOP: 5px; BORDER-BOTTOM: #5781ae 1px solid">
<DIV align=left><A style="TEXT-DECORATION: none" href="http://www.sacoapartments.co.uk"><FONT face=Arial,sans-serif color=#ffffff size=3>SACO Worldwide - [url]www.sacoapartments.co.uk[/url]</FONT></A></DIV></DIV>
<DIV style="BORDER-RIGHT: #5781ae 1px solid; PADDING-RIGHT: 20px; BORDER-TOP: #5781ae 1px solid; PADDING-LEFT: 20px; BACKGROUND: #e6e1d2; PADDING-BOTTOM: 5px; BORDER-LEFT: #5781ae 1px solid; COLOR: #333333; PADDING-TOP: 5px; BORDER-BOTTOM: #5781ae 1px solid"><FONT face="Arial, Helvetica, sans-serif" size=1><STRONG><FONT size=3>Enquiries and Reservations: 0845 122 0405</FONT></STRONG><BR>Calls from outside the UK: + 44 117 970 6999<BR>Fax: 0117 974 5939 <BR><BR>SACO is the leading provider of serviced apartments worldwide with over 2000 apartments in over 50 major business travel destinations. <BR><BR>London, Amsterdam, Barcelona, Belfast, Birmingham, Bristol, Brussels, Cardiff, Dublin, Dusseldorf, Edinburgh, Frankfurt, Glasgow, Hamburg, Jersey, Leeds, Luxembourg, Madrid, Manchester, Melbourne, Milan, Munich, Newcastle, Nottingham, Paris, Reading, Rome, Singapore, Sydney, Tallinn, Vilnius, Zurich and many more...</FONT></DIV></BODY></HTML>
<?php
}
else
{
echo "You haven't selected any apartments";
}
?>
<?php
mysql_free_result($result);
?>