|
Posted by Richard Lynch on 04/09/05 06:53
On Thu, April 7, 2005 1:17 pm, Sebastian said:
> i am developing a comment/discussion board and i want to display the
> results
> in a threaded style. so far i have it all working except this one issue:
>
> each row has an ID and a parentid, say i have 5 rows:
>
> id : 10 most oranges come from florida
> id : 16 ---- Re: most oranges come from florida (parentid 10)
> id : 22 --------- Re: most oranges come from florida (parentid 16)
> id : 24 --------- Re: most oranges come from florida (parentid 22)
> id : 28 ---- Re: most oranges come from florida (parentid 16)
>
> i want the rows to know the id directly above itself
> so for example, row 5 (id 28) will some how know its parentid (16) is not
> directly above it and is not accociated with the result its above (24)
>
> i want to 'highlight' a row when the parent it belongs to is directly
> above
> and do nothing if its not.
$query = "select ID, parentid from ...";
$lines = mysql_query($query);
$last_id = '';
while (list($ID, $parentid) = mysql_fetch_row($lines)){
$class = $last_id == $parentid ? 'highlight' : 'normal';
echo "<span class='$class'>$ID</span><br />\n";
$last_id = $ID;
}
--
Like Music?
http://l-i-e.com/artists.htm
Navigation:
[Reply to this message]
|