Hi!
//Let's imagine you've got somethnig like $row=mysql_fetch_array($result)
//
// everything won't be echoed between <%if something%> and <%endif%> if $row("something") is not set
function temp_cat() {
global $row; //this var contains an array of a rowset
//$row["tree"]="coucou";
$row["cat_img1"]="apache_pb.gif";
$tempfile = fopen("categories.html", "r");
while(!feof($tempfile))
{
$temp = fgets($tempfile, 255);
if (ereg("(.)<%if (.)%>(.*)",$temp,$out)) //here we have detected a "if" loop
$if=1;
if (ereg("(.)<%endif%>(.)",$temp,$outend))
$if=0; //out from this IF loop
if (ereg("(.)<%(.)%>(.*)",$temp,$out2) && $if==0 && isset($row[$out2[2]])) //in this case: no if condition, and the result exists...print it
echo $row[$out2[2]];
if (ereg("(.)<%(.)%>(.*)",$temp,$out2) && $if==1 && isset($row[$out[2]]) ) //in this case: the if condition is OK, print it also !
echo $row[$out2[2]];
}
}
temp_cat();
I want use this function to parse a if statament for a html file. eg
#php if statament
if ($tag) :
$tag and any html here
endif;
#use it in my html template.
#where any row of myslq table can be puted here eg: <%if
image%>, etc ...
<%if prod_id%>
<%prod_id%>
<%endif%>
Any idea or suggestion ???
kindest regards,
marcoBR