通过自引用创建面包屑 table

create breadcrumbs by self-referencing table

是否可以使用 table 自引用结构中的 PHP 在我的网站产品页面上创建面包屑列表。

我尝试从产品循环获取根类别,但结果是倒退的。 或者我尝试先获取根类别并对其进行循环,但我不知道哪个子类别是正确的子类别才能到达我想要展示的产品。

嗯,在不同的框架中可以有不同的方式。我假设您是在谈论核心 PHP。您可以编写一个 recursive function to get parents from database until you get to the root category. Put the title/id in an array and at the end user array_reverse 函数来反转数组中元素的顺序。