PHP beginner |
|
Heej allemaal,
Ik heb een probleempje bij het gebruiken van templatepower.
Als ik m'n output uit een class haal dan word de output helemaal bovenaan de pagina weergegeven.
dit is m'n template:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Forum</title>
</head>
<body>
<table border="1">
<tr>
<td>Forum</td>
<td>Topics</td>
<td>Messages</td>
<td>Last Message</td>
</tr>
{cat_index}
</table>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Forum</title> </head> <body> <table border="1"> <tr> <td>Forum</td> <td>Topics</td> <td>Messages</td> <td>Last Message</td> </tr> {cat_index} </table> </body> </html>
En dit is m'n php source:
<?
mysql_connect("localhost", "user", "pass");
mysql_select_db("db");
include('../template/class.TemplatePower.inc.php');
class Show_index {
function table() {
$q_index = mysql_query("SELECT name FROM forum_index ORDER BY id") or die(mysql_error());
while($op_index = mysql_fetch_array($q_index)) {
echo "<tr>";
echo "<td>" . $op_index['name'] . "</td>";
echo "</tr>";
}
}
}
$Show_index = new Show_index;
$tpl = new Templatepower("forum_index.tpl");
$tpl->prepare();
$tpl->assign("cat_index", $Show_index->table());
$tpl->printToScreen();
?>
<? include('../template/class.TemplatePower.inc.php'); class Show_index { function table() { echo "<td>" . $op_index['name'] . "</td>"; } } } $Show_index = new Show_index; $tpl = new Templatepower("forum_index.tpl"); $tpl->prepare(); $tpl->assign("cat_index", $Show_index->table()); $tpl->printToScreen(); ?>
Kan iemand misschien zien wat ik hier fout doe?
Ik heb het probleem niet als ik de output van de class gewoon intyp.
Dus als ik dit doe:
$tpl->assign("cat_index", "<tr><td>bla</td></tr>");
$tpl->assign("cat_index", "<tr><td>bla</td></tr>");
|