[FX.php List] Embed php into HTML or vice versa?
Jonathan Schwartz
jonathan at eschwartz.com
Thu Aug 31 19:08:40 MDT 2006
Hmmm... so how would you do that for the foreach statement?...
<?php foreach($searchResult['data'] as $key => $value)
{
echo "<tr class=\"ver12\"><td><ahref=\"famdetail.php?recid=";
$recordDetails=explode('.',$key);
$currentRecord=$recordDetails[0];
echo $currentRecord."\">".$value['FamilyName'][0];
echo "</a></td>";
}
?>
Jonathan
>On 1/9/06 10:06 AM, "Steve Hannah" <shannah at sfu.ca> wrote:
>
>> Hi Jonathan,
>>
>> One tip for making HTML-in-PHP a little easier to work with is:
>>
>> instead of
>> echo "<td>".$value['StuList'][0]."</td>";
>>
>> do
>>
>> echo "<td>{$value['StuList'][0]}</td>";
>>
>> That way you don't have to worry about forgetting a pesky
>> concatenation operator.
>> You can only do this inside double quotes, not single quotes, but it
>> works for just about any valid PHP expression.
>>
>> Best regards
>>
>> Steve
>>
>
>I'd actually handle it like this:
>
><td><?php echo $value['StuList'][0]; ?><td>
>
>This way, the HTML is HTML, the PHP is PHP. No need to contatenate, or worry
>about escaping quotes or other characters. This will work inside a foreach
>loop as you write out the data too. As I've said in earlier posts, doing it
>this way isn't always practical, but it's cleaner and more in the spirit of
>separating the two.
>
>--
>Kevin Futter
>Webmaster, St. Bernard's College
>http://www.sbc.melb.catholic.edu.au/
>
--
Jonathan Schwartz
FileMaker 8 Certified Developer
Associate Member, FileMaker Solutions Alliance
Schwartz & Company
jonathan at eschwartz.com
http://www.eschwartz.com
http://www.exit445.com
415-381-1852
More information about the FX.php_List
mailing list