This is a simple PHP script to generate a Category Tree structure based on parent/child MySQL database. Database structure looks like this: