Viewing file: schools_list.phtml (4.05 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?
class Report{
var $connection; var $table; var $structure; var $depth;
var $result; var $numrows; var $currentrow;
var $currentobj; var $prevobj;
function Report($connection,$table,$structure) { // constructor $this->connection=$connection; $this->structure=$structure; $this->depth=sizeof($structure); $this->prevobj=null; $this->currentrow=0; }
function fetchrow() { if ($this->currentrow<$this->numrows) { $this->prevobj=$this->currentobj; $this->currentobj=pg_fetch_array($this->result,$this->currentrow); $this->currentrow++; return true; } else { $this->prevobj=$this->currentobj; $this->currentobj=null; return false; } }
function matchlevel() { if ($this->currentobj==null) return 0; if ($this->prevobj==null) return 0; $level=0; while(($level<$this->depth) && ($this->currentobj[$this->structure[$level][fieldname]]== $this->prevobj[$this->structure[$level][fieldname]])) $level++; return $level; }
function open($level) { $fieldname=$this->structure[$level-1][fieldname]; $obj=$this->currentobj; $field=$obj[$fieldname];
$f=$this->structure[$level-1][begin];
if ($f) $f($obj); }
function close($level) { $fieldname=$this->structure[$level-1][fieldname]; $obj=$this->prevobj; $field=$obj[$fieldname];
$f=$this->structure[$level-1][end];
if ($f) $f($obj); }
function do_report($query) { $this->result=pg_exec($query); $this->numrows=pg_numrows($this->result); $this->currentrow=0; $this->currentobj=null; $this->prevobj=null;
while($this->fetchrow()) { $m=$this->matchlevel(); // if ($m==$this->depth) $m--; // printf("<p>matchlevel:$m depth:$this->depth</p>\n"); for($a=$this->depth;$a>$m;) { $this->close($a); $a--; } for($a=$m;$a<=$this->depth;) { $a++; $this->open($a); } } } }
function country($obj) { print("<h2><font color=\"#B06464\">$obj[country]</font></h2>\n"); }
function state_county($obj) { if ($obj[state_county]) print("<h3><font color=\"#B06464\">$obj[state_county]</font></h3>\n"); }
function state_end($obj) { print("<a href=#top>Back to top</a></p>\n"); }
function school($obj) { //name country zip state_county city street phone email webpage attn fax note styles category submit date //country state_county submit date printf("<p>"); if ($obj[name]) printf("<strong>$obj[name]</strong><br>\n"); if ($obj[street]) printf("$obj[street], "); if ($obj[zip]) printf("$obj[zip] "); printf("$obj[city]<br>\n"); if ($obj[attn]) printf("Attn: $obj[attn]<br>\n"); if ($obj[phone]) printf("Phone: $obj[phone]<br>\n"); if ($obj[fax]) printf("Fax: $obj[fax]<br>\n"); if ($obj[email]) printf("Email: <a href=\"mailto:$obj[email]\">$obj[email]</a><br>\n"); if ($obj[webpage]) printf("Webpage: <a href=\"$obj[webpage]\">$obj[webpage]</a><br>\n"); if ($obj[category]) printf("Category: $obj[category]<br>\n"); if ($obj[styles]) printf("Style(s): $obj[styles]<br>\n"); if ($obj[note]) printf("Note: $obj[note]<br>\n"); if ($obj[submit_date]) printf("Submitted: $obj[submit_date]"); printf("</p>\n"); }
$structure=array( array("fieldname" => "country", "begin" => country), array("fieldname" => "state_county", "begin" => state_county), array("fieldname" => "name", "begin" => school) );
$myreport=new Report(pg_connect("","","","","ax"),"schools",$structure); ?> <html>
<head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>AX - Kickboxing schools directory</title> </head>
<body bgcolor="#000000" text="#FEFFD2" link="#7B00FF" vlink="#B723B8" alink="#B723B8"> <div align=center> <h2><font color="#0080C0">AX</font> <font color="#008080">-</font> <font color="#B06464">Kickboxing</font></h2> <h1><font color=#00FF80>Schools Directory</font></h1> <h2>- Tell them, you saw their school on AX! -</h2> </div>
<? $myreport->do_report("select * from schools order by country, state_county, name;"); ?>
<div align=center>
<p><a href="../">Back to AX</a></p>
<p><font color="#8000FF" size="2">This page designed by "Cheryl" and Andras of the AX Web Team, 1999</font></p>
</div> </body> </html>
|