| Example 3 | |
|---|---|
| Finally we will now use the parser together with FastSQL. You will see how incredibly easy it can be to make a template-, database-driven site. Program File
# 1: <?php
HTML template file
# 0: <?
You may have noticed that this template is identical to step 2, the only difference is the way we create our data array:
First, we include the FastSQL class file require_once("./class_mysql.inc");
For FastSQL to work it needs some constants with your database settings:
define("G_HOST", "localhost");
define("G_USER", "MyUsername");
define("G_HOST", "MyPassword");
define("G_NORMDB", "MyDB");
and then create a new instance of FastSQL:
$conn = new FastSQL;Now, using the query method of FastSQL we fetch an array with all addresses $addresses = $conn->query("select * from ADDRESSES order by NAME", G_NORMDB);
This will resut in a multidimensional array holding all the data we need.
Now, to pass them to the parser all we have to do is write $params['ENTRIES'] = $addresses;Yes. It is that easy. The rest is exactly like in example 2 and the output looks the same as well See the result Note: If you want to use try this example you have to set up the table and insert your mysql data in the file example5.php |
| .GR - Domains for you |
No residence restrictions - anybody can register
Registration starting at € 16,33 / year
Web Hosting incl. .gr-Domain from € 8,90 / month
|