<? include("includes/connection.php"); ?>
<? include("includes/template.inc"); ?>
<?
$template =new Template("./templates", "remove");
$template->set_file("states", "states.tpl");
$template->set_block("states", "rows", "block");
$query ="SELECT * FROM state";
$result =mysql_query($query) or die(mysql_error());
if(mysql_num_rows($result)>0) {
$i =0;
while($row =mysql_fetch_array($result)){
$template->set_block("states", "test", "block2");
if( ($i%2) == 0){
$template->parse("block2", "test", true);
}
$i++;
$template->set_var(array("ID"=>$row["id"], "STATE"=>$row["name"]));
$template->parse("block", "rows", true);
}
}
$template->parse("OUT", "states");
$template->p("OUT");
?>