next up previous
Next: Output Up: HTML Previous: sample.htm

sample.php

Following is an example PHP script that uses SOW to read in the sample.htm template and fill in the fields.

<?php
/* sample.php */
/* read, fill in and output sample.php */

include 'dl_local.php';

dl_local("phpsowDL.so");

$env= new_env();
$sow = new_sow('sample.htm');

// stroke start section
cur_stroke_sow($sow, $env);  

// advance cursor to next section "option"
cur_next_sow($sow); 

$st= array();
$st[]= "NY";
$st[]= "TX";
$st[]= "CA";
$st[]= "FL";

$ar= array();

foreach ($st as $key=>$v){
	$ar['value']= "$key";
	$ar['selected']= ($key) ? "" : "selected";
	$ar['text']= "$v";
	update_env($env, $ar);
	cur_stroke_sow($sow, $env); 
}

// advance cursor to next section "rest"
// (prevent stroke of current section in butt)
cur_next_sow($sow);

// auto-stroke through remaining sections 
cur_butt_sow($sow, $env);

// output document
reap_sow($sow);
?>



Mark J. Olesen 2005-01-12