<?php
session_start();
include('../permission/connect_sql.php');

$sql = "SELECT [PageID],[PgroupName] FROM [WebPage] LEFT JOIN [PageGroup] ON [WebPage].[PgroupID] = [PageGroup].[PgroupID] ";
$stmt = sqlsrv_query($conn, $sql);

while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
    
    
    $pGroupName = $row["PgroupName"];
    if(!isset($group[$pGroupName])){
        $group[$pGroupName] = array();
    }
    $pageID = $row["PageID"];    
    array_push($group[$pGroupName], $pageID);
}
echo json_encode($group);
