E
elgo
hallo
ich hab hier eine kleine schleife zum auslesen von daten
die funktioniert auch ohne problem , allerdings will ich das ganze mit templates umsetzten und das macht mir probleme
hier mal mein ansatz:
hier die dazugehörige view.tmpl.html
hat irgend jemand eine idee ?
ich hab hier eine kleine schleife zum auslesen von daten
PHP:
require("../config/dbconnect.php");
$query_topic = "SELECT * FROM forum_topic ORDER BY topic_id";
$result_topic = mysql_query($query_topic);
while ($row = mysql_fetch_array($result_topic)){
$topic_id = $row[topic_id];
$topic_title = $row[topic_title];
print "<a href=?tid=" . $topic_id . ">" . $topic_title . "</a><br>";
if($tid == $topic_id){
$query_post = "SELECT * FROM forum_post WHERE topic_id='" . $tid . "' ORDER BY post_id";
$result_post = mysql_query($query_post);
while ($row1 = mysql_fetch_array($result_post)){
$post_subject = $row1[post_subject];
print $post_subject . "<br>";
}
}
}
die funktioniert auch ohne problem , allerdings will ich das ganze mit templates umsetzten und das macht mir probleme
hier mal mein ansatz:
PHP:
require("../config/dbconnect.php");
include("../include/patTemplate.php");
$tmpl = new patTemplate();
$tmpl->setBasedir( "../templates/" );
$tmpl->readTemplatesFromFile( "view.tmpl.html" );
$query_topic = "SELECT * FROM forum_topic ORDER BY topic_id";
$result_topic = mysql_query($query_topic);
while ($row = mysql_fetch_array($result_topic)){
$tmpl->addVar("topics", "TID", $row[topic_id]);
$tmpl->addVar("topics", "TTITLE", row[topic_title]);
if($tid == $topic_id){
$query_post = "SELECT * FROM forum_post WHERE topic_id='" . $tid . "' ORDER BY post_id";
$result_post = mysql_query($query_post);
while ($row1 = mysql_fetch_array($result_post)){
$tmpl->addVar("posts", "PSUBJECT", $row[post_subject]);
$tmpl->parseTemplate("posts", "a");
}
}
$tmpl->parseTemplate("topics", "a");
}
$tmpl->displayParsedTemplate( );
hier die dazugehörige view.tmpl.html
Code:
<patTemplate:tmpl name="topics">
<a href="?tid={TID}">{TTITLE}</a><br>
<patTemplate:tmpl name="posts">
{PSUBJECT}<br>
</patTemplate:tmpl>
</patTemplate:tmpl>
hat irgend jemand eine idee ?