How to use do while to build a category tree?

public function getTreeCategory($cass_category_id)
 { 
 $fullPath = $this->getCategoryName($cass_category_id);

 $query = $this->db->query("SELECT DISTINCT category_parent_id FROM" . DB_PREFIX . "cass_category WHERE cass_category_id = '" . (int)$cass_category_id . "'");

 do {
 $parent_category_id = $query->row['category_parent_id'];
 $fullPath = $this->getCategoryName($parent_category_id) . '> ' . $fullPath;
 } while ( $parent_category_id == 0);

 return $fullPath;

 }


It turns out only 2 nesting levels
March 20th 20 at 11:46
0 answer

Find more questions by tags PHP