Hi everybody! Okay, I've got phpLib installed and running properly (I assume), and have gotten some extremely simple templates to work. In fact, as long as I don't try to send more than one record to the template, it works just fine. However, when my php code looks like so:
<?php
require_once('template.inc');
require_once("../Connections/connTester.inc");
mysql_select_db($database_connTester, $connTester);
$qry="SELECT * FROM tbltest";
$result = mysql_query($qry, $connTester);
$numRows = mysql_num_rows($result);
$TEMPLATE_DIR="templates/";
$OUT_TEMPLATE="tester3.html";
$t = new Template($TEMPLATE_DIR);
$t->set_file("page", $OUT_TEMPLATE);
$t->set_block("page", "mainBlock", "main");
while($line=mysql_fetch_assoc($result)){
$t->set_var("TEXT", $line['des']);
$t->set_var("DESC", $line['des2']);
$t->parse("main", "mainBlock", true);
}
$t->pparse("OUT", "page");
?>
the template page outputs the following : "Notice: Undefined index: main in c:\Inetpub\php\template.inc on line 210." However, it then spits out both rows in the recordset, correctly formatted in the template.
The template file is simply this:
<html>
<head>
<title>Tester Template</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table border=1>
<!-- BEGIN mainBlock -->
<tr>
<td>{TEXT}</td>
<td>{DESC}</td>
</tr>
<!-- END mainBlock -->
</table>
</body>
</html>
I'm assuming this is seriously easy to figure out, but I just started messing with it literally yesterday, and don't even really know where to begin a search (a search on the board here for "Templates" brings up many results, so enlightening, some honestly beyond my understanding right now...) Are there any decent template beginner books or tuts that could help? And any suggestions on the above issue will be greatly appreciated.
Thanks!