Jump to content

XTemplate - how to integrate while loop?


newbtophp

Recommended Posts

Im using the XTemplate templating system (http://www.phpxtemplate.org)

 

All works fine, however, Im having issues when it comes to while loops:

 

I have the following within header.php:

 

<?php

include_once('./xtemplate.class.php');

$xtpl = new XTemplate('header.xtpl');

$result = mysql_query("SELECT username FROM site_table");

while($row = mysql_fetch_assoc($result)) {
echo $row['username'];
}
$xtpl->parse('header');
$xtpl->out('header');
?>

 

And the following with header.xtp:

 

<td width="239" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="5">
<tr>
<td bgcolor="#8b0000">
<div align="center">User List</div>
</td>
</tr>
<td valign="top" bgcolor="#660000">
<div align="center">
<table width="100%" border="0" cellpadding="0" cellspacing="2">
<tr>
<td>
<div align="left">
<tr>
<td width="93%" bgcolor="#500F0C">
<div align="left">
{USERNAME}
</div>
</td>
</tr>
</div>
</td>
</tr>
</table>
</div></td>
</tr>
</table>

 

How would I go by doing the above?

Link to comment
https://forums.phpfreaks.com/topic/209057-xtemplate-how-to-integrate-while-loop/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.