当父代= 0时表示类别当parent = 1时表示子类别1连接到类别1(id = 1)当parent = 2表示子类别2连接到类别2(id = 2)时当父级...以此类推直到19个类别(id = 19,父级= 0)我需要根据用户在类别字段中的选择将子类别的名称带到子类别表单字段中。类别字段工作正常。id parent name active1 0 Arts & Entertainment 02 0 Automotive 03 0 Business & Professional Serv. 14 0 Clothing & Accessories 05 0 Community & Government 06 0 Computers & Electronics 17 0 Construction & Contractors 08 0 Education 09 0 Food & Dining 010 0 Health & Medicine 011 0 Home & Garden 012 0 Industry & Agriculture 013 0 Legal & Financial 114 0 Media & Communications 015 0 Personal Care & Services 016 0 Real Estate 017 0 Shopping 018 0 Sports & Recreation 019 0 Travel & Transportation 034 1 Acting Schools 135 1 Aerial Photographers 136 1 Arcades & Amusements 137 1 Art Classes 138 1 Art Galleries & Dealers 139 1 Art Schools 11.这是对category字段的查询,它很好用,并为我们提供了用户的选择($ judgePick)$db->setQuery('SELECT name FROM #__professional_categ WHERE parent=0 AND active=1 ORDER BY name ASC');2.这是试图解决的子类别字段查询$judgePick = JRequest::getVar('category');$db = JFactory::getDBO();假设1-包含='。$ db-> quote($ judgePick)的id假设2-对于父级> 0,必须等于假设1中用户选择的ID预期结果子类别字段仅在用户选择ID等于父项的类别字段($ judgePick)中根据用户的选择具有名称。换句话说,例如,艺术与娱乐是类别(parent = 0)并具有(id = 1),并且当用户在类别表单字段中选择它时,子类别表单字段应显示所有带有(parent = 1)的名称
2 回答
Cats萌萌
TA贡献1805条经验 获得超9个赞
那这个呢
$db->setQuery("SELECT name FROM #__professional_categ WHERE parent=$judgePick AND active=1 ORDER BY name ASC");
- 2 回答
- 0 关注
- 123 浏览
添加回答
举报
0/150
提交
取消