Greetings!
I am working on the message board sysrem, and I am having trouble with recursion levels... I did some very simple calculations, how should threads be treated, but I have found out, that what I did is not exactly the best solution... Now what I should do:
level 0: topic
level 1: Re: topic
level 2: Re: Re: topic
level 3: Re: Re: Re: topic
level 1: Re: topic
level 0: new topic
Now I have calculations made for that it adds or removes a level, whenever there is right change of numbers, that it counts ++ or --, but this is not the right thing... I need to be able to "jump" the levels, but I just donno, how to tag levels with numbers... This is my current code:
function spaces($count)
{
$i=0;
while ($i != $count)
{
echo ("-");
$i++;
if ($i>200)
{
$i=0;
$count=0;
}
}
}
function showthreads($pID)
{
global $tags;
global $number;
global $color_count;
$color_count++;
$dateToUse = Date("U");
// Show all the replies.
$query = "SELECT * FROM msgboard WHERE (Parent = " . $pID . ") ORDER BY ID;";
$result = mssql_query($query);
$numRows = mssql_num_rows($result);
$CurrentRow = 0;
while($CurrentRow < $numRows) {
$mID = mssql_result($result,$CurrentRow,"ID");
$mTitle = mssql_result($result,$CurrentRow,"Title");
$mPoster = mssql_result($result,$CurrentRow,"Poster");
$mCreated = mssql_result($result,$CurrentRow,"Created");
$mParent = mssql_result($result,$CurrentRow,"Parent");
$counter++;
if($counter==1)
{
$tags=$tags+2;
}
elseif((($mParent==$mID) && $counter>=2 && ($number==$counter) || ($number>$counter)))
{
$tags=$tags-2;
}
// Display the reply.
if($mParent=="0")
{
$counter=0;
$tags=0;
}
if ($color_count %2==0)
{
echo"<tr>";
echo"<td bgcolor='#c0c0c0'>";
spaces($tags);
echo "$counter <A HREF=\"msgboard.php3?mID=" . $mID . "\">$mTitle</A>";
echo " ($mCreated) - by <A href=\"mailto:$mRepliere\">$mPoster</a><BR>\n";
echo"</td>";
echo"</tr>";
}
else
{
echo"<tr>";
echo"<td bgcolor='#ffffff'>";
spaces($tags);
echo "$counter <A HREF=\"msgboard.php3?mID=" . $mID . "\">$mTitle</A>";
echo " ($mCreated) - by <A href=\"mailto:$mRepliere\">$mPoster</a><BR>\n";
echo"</td>";
echo"</tr>";
}
$number=$counter;
showthreads($mID);
$CurrentRow++;
}
}
Please, please help!
Best regards. zer0Kode