to all guru
i have a problem in my template parser script
here is the code
my templategenerator.php
<?
mysql_connect("localhost","","");
mysql_select_db("mydatabase");
$templateFile="template.tpl";
$output=file_get_contents($templateFile);
$html_lines=explode("\n",$output);
$startline=0;
$endline=0;
for ($line_num=0;$line_num<count($html_lines);$line_num++)
{
if (preg_match("/<!--START HERE -->/",$html_lines[$line_num]))
$startline=$line_num;
if (preg_match("/<!-- END HERE -->/",$html_lines[$line_num]))
$endline=$line_num;
}
$dislist='';
$grabline=0;
$first='';
$last='';
for ($grabline=$startline+1;$grabline<$endline;$grabline++)
{
$dislist =$dislist.$html_lines[$grabline];
}
$replaceitem='';
$first="";
$last="";
$stringarray=array("{member.NAME}","{member.Last}");
$query=mysql_query("select * from members");
while ($result=mysql_fetch_object($query))
{
$first=$result->firstname;
$last=$result->lastname;
$replaceitem .=str_replace($stringarray,array($first,$last),$dislist); // note this is an array this is the problem i encounterd in dislaying
}
echo preg_replace('#{(([a-z0-9-]+?.)+?)([a-z0-9-]+?)}#is', $replaceitem,$output );
?>
and my template.tpl
blah blah blah{FULLTEST}
<table border="1">
<tr><Td valign="top">astig frist table</Td><td><table width="29" border="1">
<tr><td align="center" colspan="3">TESt only beader</td></tr>
<!--START HERE -->
<tr>
<td align="center">{member.NAME}</td>
<td>M</td><td>{member.Last}</td>
</tr>
<!-- END HERE -->
</table></td><td valign="bottom">4th table </td></tr>
</table>
and nothing follows
my problem is this
the code complete display all data using the template however, the display will repeat itself based from the number of arrays (using the str_replace)
example: $array=array("{Firstname},"{lastname});
this should only display
George Bush
and not
George Bush
George Bush
since the
str_replace($array,array(fieldname,etc);$templatecursive);
it is stored in array
any one who can really help me ????????????????????