Coders will need to prepare a script that displays the Address book entries as such:
handler.php
<?php 1: $template_filename = "TEMPLATE.html"; 2: 3: ..... database extraction codes (omitted) .... 4: 5: /* =============================================================== */ 6: /* ====================== Replacement Rules ====================== */ 7: /* =============================================================== */ 8: 9: $replacement_rules = array ( 10: array ("<!--NAME-DATA-->", "0"), 11: array ("<!--ADDRESS-DATA-->", "1") 12: ); 13: 14: /* =============================================================== */ 15: 16: $n_fcontents = template_parser ($template_filename, $replacement_rules, $recordset_array); 17: while (list ($line_num, $line) = each ($n_fcontents)) 18: { 19: echo "$line"; 20: } ?>
What the above script does is to set rules to display our
database-retreived record fields in appropriate columns in the HTML
tables. These rules will be stored in
as defined above.
database-retreived record fields in appropriate columns in the HTML
tables. These rules will be stored in
$replacement_rules
arrayas defined above.
The elements of
how to “fill in the blanks”.
$replacement_rules
array simply let our script knowhow to “fill in the blanks”.
The variable :
records which we retrieved from database.
$recordset_array
is a 2-dimension array that containsrecords which we retrieved from database.
+---------------------------------+ | Alvin | Block 112 Bedok Road | +---------------------------------+ | Robert | 23 Livingstone Road | +---------------------------------+ : : +---------------------------------+ | John | 556 Everton Park Road | +---------------------------------+
Line 10 (and line 11) of the code simply is a “rule” that instructs
PHP script to replace occurances of the string
with
in
PHP script to replace occurances of the string
<!--NAME-DATA-->
with
FIELD 1
(array is “zero-based”) of the recordset providedin
$recordset_array
array.