Announcement

Collapse
No announcement yet.

Dynamic Menu not showing items in order storted

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dynamic Menu not showing items in order storted

    Here's my code. It is not showing menu items in order by master_item, item_number although I"ve specified that in my query. It seems to be sorting in descending order. 1.3, 1.2, 1.0. All of my numeric fields (id, master_item, and item_number) are INT 11. I have tried changing my query to include DESC. I have removed all indexes except ID at the database level. I change all item_number values to zero; thinking it might do something different - it does not.
    sc_appmenu_reset("menu");

    //2018-01299:bh Apps with link not called from elsewhere that user has permission to run
    $array1= array();
    sc_select(rs, "SELECT id FROM app_menu WHERE called_from = '' AND link IN (SELECT app_name FROM sec_groups_apps WHERE group_id = '1' AND priv_access = 'Y') ") ;
    while(!$rs->EOF)
    {
    $array1[] = $rs->fields[0];
    $rs->MoveNext();
    }
    $rs->Close();

    //2018-0129:bh Master of linked items - only those with a master greater than 1 - has duplicates
    $array2= array() ;
    foreach($array1 as $k => $linked_item){
    sc_select(rs, "SELECT master_item FROM app_menu WHERE id = $linked_item AND master_item != 0") ;
    while(!$rs->EOF)
    {
    $array2[] = $rs->fields[0];
    $rs->MoveNext();
    }
    $rs->Close();
    }

    $result = array_merge($array1, $array2);
    /*print_r($result); //Show me the linked array*/

    foreach($result as $m => $item_id) {
    $sql = "SELECT id, master_item, description, link, hint, item_number FROM app_menu WHERE id = $item_id ORDER BY master_item, item_number";
    sc_lookup(ds, $sql);

    foreach({ds} as $arr_menu_item)
    {
    $menu_item = "item_".$arr_menu_item[0];

    if($arr_menu_item[1] == 0)
    {
    $master_id = "";
    }else{
    $master_id = "item_".$arr_menu_item[1];
    }

    sc_appmenu_create("menu");
    sc_appmenu_add_item("menu", $menu_item, $master_id, $arr_menu_item[2], $arr_menu_item[3], "", "", $arr_menu_item[4], "");
    } //for each item
    } //for each result
Working...
X