Welcome Guest, Not a member yet? Register   Sign In
Displaying Parent/Child lists
#4

[eluser]thunder uk[/eluser]
A slightly easier way to do it (assuming you do pull the staff and department info together and it's ordered by department) would be to set a flag as you loop through the record set.

eg

Code:
$current_department = "";

foreach($recordset as $row)
{
    if($current_department != $row['department']) // If the department has changed
    {
        $current_department = $row['department']; // Set the current flag to the new department
        echo("<b>" . $current_department . "</b>"); // and output the department header
    }

    // Output the staff details here

}

That way, the header row will only get output when the department changes. The above code would need to be fixed up a little obviously according to the fields in your select statement.


Messages In This Thread
Displaying Parent/Child lists - by El Forum - 06-30-2007, 02:26 PM
Displaying Parent/Child lists - by El Forum - 06-30-2007, 04:23 PM
Displaying Parent/Child lists - by El Forum - 06-30-2007, 05:25 PM
Displaying Parent/Child lists - by El Forum - 07-01-2007, 03:46 AM
Displaying Parent/Child lists - by El Forum - 07-01-2007, 09:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB