- Lets say I have a template (news_template) that its a NEWS <table> with some fields like:
<tr>
<td>{TITILE}</td>
<td>{TEXT}</td>
<td>{SCREENS}</td>
</tr>
It must be shown in the main tamplete, within the var {NEWS} like:
<table>{NEWS}</table>
- I have a sql database with a table with 3 fields:
'title' class VARCHAR (for ex: "title1");
'text' class TEXT (for ex: "text1");
'screens' class TINYTEXT (for ex: "img1.gif,img2.gif,img3.gif");
My idea is that the table shown above will be shown as:
<td>title1</td>
<td>text1</td>
<td><img src="img1.gif"><img src="img2.gif"><img src="img3.gif"></td>
My code at the moments looks like:
while ($news = mysql_fetch_array ($sqlnews)) {
$screens = explode(",", $news[2]);
foreach($screens as $screen){
$pics .= "<img src=\"http://localhost/images/reviews/$screen\" width=\"100\" height=\"100\"/>\n";
$t->set_var("SCREENS",$pics);
}
$t->set_var("TITLE",$news[0]);
$t->set_var("TEXT",$news[1]);
$t->parse("NEWS","news_template",true);
}
The images are shown but, each row of the field shows the images of the pass row of the field, i mean, the NEWS1 shows its 3 pics but the NEWS2 shows its 3 pics plus the 3 pics of NEWS1....where am i going wrong?