<?

////////////////////////////////
$EnforceSession = true;
$bDummyDataTipExclude = true;
include "includes/includes.php";
////////////////////////////////

// Header
include "includes/header.php";

$ViewActiveMembers = false;

// Begin Template
$tp = new PhpTemplate;
for( $tp->StartFromFile( "templates/lessons.template" ); $tp->NextAndEchoOutput(); ) 
{

	CheckGlobalEscapes( $tp );

	if( $tp->IsEscape("LESSONS") )
	{
		
		// Connect
		$db = mysql_connect("localhost", $gblMySqlUser, $gblMySqlPass);
		mysql_select_db($gblMySqlDb, $db);
		
		// Retrieve data
		$query = "SELECT * FROM lesson WHERE site = '" . $gblSiteName . "' ORDER BY number";		
		$result = mysql_query($query, $db);
		
		$RowIndex = 0;
						
		// Loop results
		for( $RowIndex = 0; $a = mysql_fetch_array($result); $RowIndex++ )
		{
			$Record = new PhpSqlRow;
			$Record->SetAsArray($a);
			
			$tpElem = new PhpTemplate;						
			for( $tpElem->Start( $tp->GetEscapeArgument() ); $tpElem->NextAndEchoOutput(); ) 
			{
			
				CheckGlobalEscapes($tpElem);
				
				if( $tpElem->IsEscape("ID") ) echo $Record->GetValue("id");
				else if( $tpElem->IsEscape("NAME") ) echo $Record->GetValue("name");
				else if( $tpElem->IsEscape("INDEX") ) echo $RowIndex + 1;
				else if( $tpElem->IsEscape("IF-ODD-ROW") && ($RowIndex % 2) == 1 ) echo $tpElem->GetEscapeArgument();								
			}
			
		}			
				
	}


}

// Footer
include "includes/footer.php";

?>
