[FX.php List] Embed php into HTML or vice versa?
Jonathan Schwartz
jonathan at eschwartz.com
Thu Aug 31 17:57:24 MDT 2006
Kevin,
I have yet to delve into smarty.php, but this is an example of my
html embedded into php: Just to be clear, I'm barely out of the
"very thankful" stage I can at least get the code to work. ;-) It
can take a lot of time to locate that missing syntax error.
J
<?php foreach($searchResult['data'] as $key => $value)
{//start for each
echo "<tr class=\"ver12\"><td><ahref=\"famdetail.php?recid=";
$recordDetails=explode('.',$key);
$currentRecord=$recordDetails[0];
echo $currentRecord."\">".$value['FamilyName'][0];
echo "</a></td>";
echo "<td>".$value['StuList'][0]."</td>";
echo "<td>".$value['Address1'][0]."</td>";
echo "<td>".$value['City'][0]."</td>";
echo "<td>".$value['State'][0]."</td>";
echo "<td>".$value['Zip'][0]."</td>";
echo "<td align=\"right\"><a href=\"editfamorder.php?recid=";
echo
$currentRecord."\">$".number_format($value['AmtTotal'][0],'2',".","");
echo "</a></td>";
echo "<td align=\"right\"><ahref=\"lunchdetail.php?recid=";
echo
$currentRecord."\">$".number_format($value['LunchTotalPrice'][0],'2',".","");
echo "</a></td>";
echo "<td
align=\"center\">".$value['PTAMembership'][0]."</td>";
echo "</tr>";
} //end for each
?>
At 9:29 AM +1000 9/1/06, Kevin Futter wrote:
>On 1/9/06 6:16 AM, "Jonathan Schwartz" <jonathan at eschwartz.com> wrote:
>
>> I'd like to get better at coding my scripts.
>>
>> One thing that I have not developed a sense for yet: when it is best
>> to embed php tags into html versus embedding html into php code.
>>
>> I tend to waste the most amount of time solving parse errors when
>> embedded html into php, it seems, especially in dealing with quotes
>> and such.
>>
>> I hope that this question makes sense.
>>
>> Thanks
>>
>> Jonathan
>>
>
>The way to look at it is from the perspective of separating logic from other
>elements of page rendering (document structure, presentation and behaviour).
>On that basis alone, I endeavour to keep my PHP and HTML as separate as
>possible (which often isn't very). Normally I try to just print PHP variable
>values into an HTML element or attribute and move on. It's not always
>possible, but mixing them up either way just makes for a messy document in
>which all the separate elements are mashed up.
>
>--
>Kevin Futter
>Webmaster, St. Bernard's College
>http://www.sbc.melb.catholic.edu.au/
>
>
>
>------------------------------------------
>This e-mail and any attachments may be confidential. You must not
>disclose or use the information in this e-mail if you are not the
>intended recipient. If you have received this e-mail in error,
>please notify us immediately and delete the e-mail and all copies.
>The College does not guarantee that this e-mail is virus or error
>free. The attached files are provided and may only be used on the
>basis that the user assumes all responsibility for any loss, damage
>or consequence resulting directly or indirectly from the use of the
>attached files, whether caused by the negligence of the sender or
>not. The content and opinions in this e-mail are not necessarily
>those of the College.
>
>
>_______________________________________________
>FX.php_List mailing list
>FX.php_List at mail.iviking.org
>http://www.iviking.org/mailman/listinfo/fx.php_list
--
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