Search code examples
phpmysqlsortingzen-cart

Zen Cart place MySQL results within array inside of MoveNext() tags


I'm wondering if I could have some help, I would like to place the following inside an array so I can change the sort order using PHP as sorting via MySQL does not seem to be working but am unsure how to go about doing it, any help would be appreciated.

                      global $db;


                  $sql = "select c.categories_id, cd.categories_name, cd.categories_menu_name, c.parent_id, c.sort_order 
                        from " . TABLE_CATEGORIES . " c left join " . 
                        TABLE_HIDE_CATEGORIES . " hc on c.categories_id = hc.categories_id, " . 
                        TABLE_CATEGORIES_DESCRIPTION . " cd 
                        where c.categories_id = cd.categories_id 
                        and c.categories_status=1 
                        and (hc.visibility_status IS NULL or hc.visibility_status < 2) 
                        and c.show_in_drop2=1 and cd.language_id = '" . (int)$_SESSION['languages_id'] . "'  and cd.categories_id = ".(int)$sub_categories->fields['categories_id']." 
                        order by c.sort_order, cd.categories_name, c.parent_id";
                  //$sql = "select categories_name, categories_id from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = ".(int)$sub_categories->fields['categories_id']." order by categories_name";


                  $sub_categories_name = $db->Execute($sql);

                  if ($sub_categories_name->RecordCount() > 0) {
                    //$result .= 'Cat ID: ' . $sub_categories_name->fields['categories_id'] . '<br /> Cat Name: ' . $sub_categories_name->fields['categories_name'] . '<br /> Sort Order: ' . $sub_categories_name->fields['sort_order'] . '<br />';
                    if (strlen($sub_categories_name->fields['categories_menu_name']) < 1) {
                        $sub_cat_menu_name = $sub_categories_name->fields['categories_name'];
                    } else {
                        $sub_cat_menu_name = $sub_categories_name->fields['categories_menu_name'];
                    }
                    //BOF: Split into multiple columns
                    if ($sub_categories_name->fields['categories_id'] == 26) {
                        $column_split = '<li class="column-split"><span>&nbsp;</span>';
                    } else {
                        $column_split = '';
                    }
                    //EOF: Split into multiple columns
                    $result .= $column_split.'<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $sub_categories_name->fields['categories_id']) . '">' . $sub_cat_menu_name . '</a>';
                  }

              $sub_categories->MoveNext();
            }

Many thanks,

Costa


Solution

  • You can solve this by resetting the page to it's original code and changing $max_level at the top of the page to 3, I feel silly for not noticing that earlier!