<?php

// ***************************
// *                         *
// *  Menu Builder Utilities *
// *                         *
// ***************************

  function get_menu_label_list($field = "*",$default_select = false,$where_string = "") { //This has the properties for the optios list 
  include ("db_connection.php");

                              $query = "SELECT " . $field . " " .
                                       "FROM page_name_suggestions ";
  if ($default_select)       $query .= "WHERE default_select=true ";
  if (!empty($where_string)) $query .= "WHERE " . $where_string . " ";
                             $query .= "ORDER BY sort_order ASC";

  $result = $bwb_wiz_dbh->query($query);
  $rows = $result->fetchALL(PDO::FETCH_ASSOC);


//print "<pre style=\"text-align:left;\">";
  //  print_r($rows);
    //print "</pre>";

    return $rows;
  }

  function get_menu_label_selector($row,$selected="",$menu_rows) { //This populates a select box

    static $myMenuSelector = null;
    if ($myMenuSelector === null) {
      $myMenuSelector = get_menu_label_list("link_text");   //This is the list of the select options to populate select with
    }
    $myString1 = str_pad("", 18) . "<select name='menu_label_name_row" . $row . "' \n";
    //$myString1 .= str_pad("", 25) . (($row < $menu_rows) ? "<select name='menu_label_name_row" . $row : "<select name='menu_label_name_row_add")."' \n";
    $myString1 .= str_pad("", 25) . "class='edit_value hide_value' \n";
    $myString1 .= str_pad("", 22) . "onchange='set_value(this);' \n";
    $myString1 .= str_pad("", 24) . "onblur='set_value(this);' >\n";
    $myString1 .= str_pad("", 20) . "<optgroup label=' *** select label *** '>\n";
    foreach ($myMenuSelector as $val) {
    $myString1 .= str_pad("", 22) . "<option value='" . $val["link_text"];
    $myString1 .= ($val["link_text"]===$selected?"' selected>":"'>");
    $myString1 .= $val["link_text"] . "</option>\n";
    }
    $myString1 .= str_pad("", 20) . "</optgroup>\n";
    $myString1 .= str_pad("", 18) . "</select>\n";

    return $myString1;
  }

?>