$rowCount = 0;
$rowColors = array('0' => '#ffffff', '1' => '#CCCCCC');
while ($row = mysql_fetch_array($result)) {
$color = $rowCount++ % 2; // result will alternate 0 and 1
// indent and display the title of this child
echo '<tr style="background: '.$rowColors[$color].';"><td>'.$row['id'].'</td><td>'.str_repeat(' -- ',$level).$row['title']."</td><td>View</td><td>Edit</td><td>Delete</td></tr>";
// call this function again to display this
// child's children
displayTree($row['id'], $level+1, $tableName);
}