Проблем с replace_tags функция и MySQL

jooorooo

Registered
значи, сега се мъча да разбера тези темплеити :) въпроса е че не става.

имам следните файлове:

index.php

Код:
<?php
$server = "localhost";
$dbusername = "jooorooo";
$dbpassword = "***";
$db_name = "testova";



require_once("lib/template.php");

$page = new Page("themes/default/template.html");
mysql_connect($server, $dbusername, $dbpassword)or die("Сайтът не може да се свърже към базата данни");
@mysql_select_db($db_name) or die("Грешна база данни");
$query="SELECT * FROM `cat` ORDER BY `cats` ASC";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

$i=0;
while ($i < $num) { 

$cats=mysql_result($result,$i,"cats");
$page->replace_tags(array(
"logo" => "<img border='0' src='images/logo.PNG' width='40%' height='100%'>",
"title" => "Тест",
"descript" => "Кво прайш",
"main" => "алабала",
"menu" => "<a href='index.php'>Начало</a>",
"left" => "Регистрация",
"right" => "Контакти",
"footer" => "Copyright © 2006",
"up" => "<a href='download/index.php'>Свали</a>",
"test" => "<div id=\"div\"><a href=catview.php?cats=$cats>$cats</a></div>"
));
$i++;
}
$page->output();


?>

template.html

Код:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>StarMechanik</title>
</head>
</table>


<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1" height="401">
  <tr>
 <td width="100%" height="64" bgcolor="#000066">
{logo}</td>
</td>
  </tr>
  <tr>
    <td width="100%" height="336">
    <style> 
.cell { 
   border: 1px solid black; 
   vertical-align: top; 
   text-align: center 
} 
#div{
width:85px;
height:130px;
float:left;
}
    </style> 
 <body>
<table style="width: 100%; height: 440;"> 
   <tr> 
      <td class="cell" style="width: 20%;" height="436">
      <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2">
        <tr>
          <td width="100%">
        
		{menu}
</div>
</div>
<div id="leftcol">
          </td>
        </tr>
        <tr>
          <td width="100%">
          {up}
</div>

<div id="leftcol">
          </td>
        </tr>
        <tr>
          <td width="100%">
          {left}
</div>
<div id="rightcol">
          </td>
        </tr>
        <tr>
          <td width="100%">
          {right}
</div>
<div id="main">
          </td>
        </tr>
      </table>
      </td> 
      <td class="cell" style="width: 60%;" height="436">{test}</td> 
      <td class="cell" style="width: 20%;" height="436">Advertisements</td></tr></td></tr></table></table>
<p align="center">
{footer}
</div>
</div>
<div id="leftcol">
</p>

и template.php

Код:
<?php
class Page
{
var $page;

function Page($template = "template.html") {
if (file_exists($template))
$this->page = join("", file($template));
else
die("Файл $template не беше намерен.");
}

function parse($file) {
ob_start();
include($file);
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}

function replace_tags($tags = array()) {
if (sizeof($tags) > 0)
foreach ($tags as $tag => $data) {
$data = (file_exists($data)) ? $this->parse($data) : $data;
$this->page = eregi_replace("{" . $tag . "}", $data,
$this->page);
}
else
die("Няма избрани тагове за промяна!");
}

function output() {
echo $this->page;
}
}
?>

значи в базата съм сложил 4 записа, а то ми показва само 1-вия...

http://webjo.no-ip.org/test1/New%20Folder%20(3)/

нещо бъркам ама къде?
 

Горе