<!DOCTYPE html>
<html lang="en">

<head>
  <meta http-equiv="Content-Language" content="en-us">
  <title>Doc Root</title>
  <meta charset="utf-8">

  <link rel="stylesheet" href="/ext/bootstrap/bootstrap.min.css">
  <link rel="stylesheet" href="/ext/bootstrap/bootstrap-theme.min.css">
  <link rel="stylesheet" href="/site/css/stickythead.css">
  <link rel="stylesheet" href="/site/css/bootstrap.css">
  <link rel="stylesheet" href="/site/css/multiselect.css">
  <link rel="stylesheet" href="/site/css/slider.css">
  <link rel="stylesheet" href="/site/css/style.css">

  <script src="/ext/jquery/jquery-3.1.1.min.js"></script>
  <script src="/ext/bootstrap/bootstrap.min.js"></script>
  <script src="/ext/jquery/jquery.stickytableheaders.min.js"></script>
  <script src="/site/js/main.js"></script>

</head>
<body>

<h2>Test Start</h2>  
<br>Object<br>

<?php

require_once($_SERVER['DOCUMENT_ROOT'] . '/sys/db.php');

$dal = new DAL();

$sql = "SELECT id, menugroup_id " .
       "FROM login ";
$logins = $dal->query($sql);

foreach ($logins as $login) {
  $lo_id = $login->id;    
  $mg_id = $login->menugroup_id;
  $sql = "SELECT LM.id, LM.mainmenu_id, MM.rank  " .
         "FROM loginmenuold LM, mainmenu MM " .
         "WHERE LM.menugroup_id = $mg_id AND MM.id = LM.mainmenu_id ";
  $groups = $dal->query($sql);
  
  foreach ($groups as $group) {
//    print_r ($group);    
//    print_r ("<br>");    
    $mm_id = $group->mainmenu_id; 
    $rank = $group->rank;
    
  $sql = "INSERT loginmenu (login_id, group_id, mainmenu_id, rank)  " .
         "VALUES ($lo_id,$mg_id, $mm_id, ($rank * 10)) ";
  $result = $dal->query($sql);
    
//print_r ("lo:$lo_id mg:$mg_id mm:$mm_id<br>");    
  }
}

?>

<script>

</script>


</body>
</html>































