PHP Classes

File: three_color.php

Recommend this page to a friend!
  Classes of Hans Körber   Phptempt   ???   Download  
File: ???
Role: Example script
Content type: text/plain
Description: output of a HTML table with rows in three different colours
Class: Phptempt
Template engine for PHP and Java
Author: By
Last change:
Date: 22 years ago
Size: 860 bytes
 

Contents

Class file image Download
<?php
    $data
["name"] = array ("hans", "dennis", "christine", "karl", "horst");
   
$data["town"] = array ("T&uuml;bingen", "Reutlingen", "Paris", "Toronto", "G&ouml;hlen");

   
// include API:
   
include ("phptempt.php");

   
// include precompiled template:
   
$t = new phptempt ("three_color.inc");

    for (
$i=0; $i<sizeof($data["name"]); $i++) {

       
$t->begin ("aBlock");
        if (
$i % 3 == 0)
           
$t->begin ("nested1");
        else if (
$i % 3 == 1)
           
$t->begin ("nested2");
        else
           
$t->begin ("nested3");

       
// add data to one of the three blocks in turn:
       
$t->addVal ("NAME", $data["name"][$i]);
       
$t->addVal ("TOWN", $data["town"][$i]);

        if (
$i % 3 == 0)
           
$t->end ("nested1");
        else if (
$i % 3 == 1)
           
$t->end ("nested2");
        else
           
$t->end ("nested3");
       
$t->end ("aBlock");
    }

   
// output template:
   
$t->out ();
?>