[FX.php List] Embed php into HTML or vice versa?
Steve Hannah
shannah at sfu.ca
Thu Aug 31 18:06:31 MDT 2006
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
----------------------------------------
Steve Hannah
Web Services Developer
Faculty of Applied Sciences
Simon Fraser University
shannah at sfu.ca
604-268-7228
Homepage: http://www.sjhannah.com
--
Need to build a database driven web application quickly?
Try Dataface: http://fas.sfu.ca/dataface
On 31-Aug-06, at 4:57 PM, Jonathan Schwartz wrote:
> 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
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>
More information about the FX.php_List
mailing list