|
Lesson 2 - More Basics
PHP code and Fusion pages -
Fusion is an HTML code generator. A mostly WYSIWYG code generator. It's NOT an HTML editor. PHP extends the power of Fusion by allowing you to add dynamic content to your web pages - in part by generating HTML code itself when you need it to.
The "Insert HTML" box (aka 'the box') you access with Ctrl+T is still awkward to use in Fusion 9 and hopefully will by improved in the version of Fusion that follows. It's limitations are many - but it's
what we have to use for now. We usually write code in PHPNotepad and copy it into the box. Then we fine-tune (read: correct our typos) in the box.
Using the box, you can insert code such as HTML code you write. For example; a lengthy list of items for a form combo box is often easier to place on a form by inserting code rather than using
Fusion Forms Combo Box tool. It can also be used to insert Javascript and, of course PHP scripts. Or any combination of these. The box should probably be titled "Insert Code" instead of "Insert HTML", since you are not at all
limited to only inserting HTML code.
When you insert code, you can drop in and out of PHP and into HTML as appropriate. In the example below, the two code snippets are equivalent. (just imagine you're looking at two "Insert HTML" boxes)
Note: notice that when you 'echo' or 'print' the results of a function - you don't use " " around the function.
|
Simple table using PHP - two methods
|
|
<? echo "<Table>"; echo "<TR>"; echo "<TD><P>"; echo date("F jS, Y");
echo "</P></TD>"; echo "</TR>"; echo "</TABLE>; ?>
|
<Table> <TR> <TD><P> <? echo date("F jS, Y"); ?> </P></TD>
</TR> </TABLE>
|
|
If you have CSS turned on in Fusion (highly recommended) the generated table will use the styles you have set in Fusion. Or you can insert your own style or formatting code if you wish to override the CSS styles you have set. |