I am making a forum script, this part is basically parsing the html for the categories then the html for the rows inside. For some reason the forums repeat themsleves and I have tried everything to clear the values incudling $forum = ''; and unset($forum); but nothing is working, and 2 hours later all I have achieved is a majour headache, please help.
<?php
/***********************
Name: Mi-Dia (http://www.mi-dia.co.uk )
Author: Christopher Shaw
This file belongs to Mi-Dia, it may be freely modified but this notice, and all copyright marks must be left
intact. See COPYING.txt
************************/
$STYLE = new style();$tpl = $STYLE->open('forum/home.tpl');
$cat = $STYLE->getcode('category',$tpl);
$forumcode = $STYLE->getcode('row',$tpl);
if ( $account['level'] < '1') {$where = "AND staff = '0'"; $catw = "WHERE staff='0'";}else{$where="";$catw="";}
$postsql = mysql_query("SELECT * FROM ".$dbslave."." . $prefix . "_forum_cats $catw ORDER BY sort;");
while ($row = mysql_fetch_array( $postsql )) {
///FORUM
$cat_id = $row['id'];
$forumsql = mysql_query("SELECT * FROM ".$dbslave."." . $prefix . "_forum_forums WHERE cat_id = '$cat_id' AND parent_id = '0' $where ORDER BY sort;");
$forum='';
while ($forumrow = mysql_fetch_array( $forumsql )) { $forum = $STYLE->tags($forumcode,array("TOPIC" => $forumrow['name']));$class = 1 - $class;
/// FORUM
$cat .= str_replace($cat,$forum,$cat);}
$cat = str_replace($forumcode,'',$cat);
$category .= $STYLE->tags($cat,array("NAME" => $row['name']));
$class = 1 - $class;
}
$forum = '';
$catcode = $STYLE->getcode('category',$tpl);
$tpl = str_replace($catcode,$category,$tpl);
print '<BR>Origional: '.$catcode.'<br>orum Code:'.$forum.' <br>Unparsed: '.$cat.' <br>Parsed: '.$category.'<br>FINAL:'.$final;
print $forum;
$output .= $STYLE->tags($tpl,'');
?>
There is alot of debugging code in there, but I have added ////FORUM around the area of concern, please help. Thanks