<?php

include("./script/php/permission/connect_sql.php");
$group = array(array('Admin', '4'), array('Manager', '3'), array('Editor', '2'), array('User', '1'));
$Pgroup = array('MyAccount');




// $PageIDs = array();
// $sql = "SELECT [PageID] FROM [dbo].[WebPage]";
// $fetchResult = sqlsrv_query($conn, $sql);
// while ($row = sqlsrv_fetch_array($fetchResult,SQLSRV_FETCH_NUMERIC)) {
//     array_push($PageIDs,$row[0]);
// }



for ($i = 0; $i < count($Pgroup); $i++) {
    for ($j = 0; $j < count($group); $j++) {

        $sql = 'INSERT INTO [GroupRight]
        ([GroupID]
        ,[PgroupID]
        ,[RightID])
        VALUES
            (?,?,?)';
            //$stmt = sqlsrv_query($conn, $sql, array($group[$j][0],$Pgroup[$i],$group[$j][1]));
            if( $stmt === false ) {
                if( ($errors = sqlsrv_errors() ) != null) {
                    foreach( $errors as $error ) {
                        echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
                        echo "code: ".$error[ 'code']."<br />";
                        echo "message: ".$error[ 'message']."<br />";
                    }
                }
            }
            echo('[GroupID]: ' . $group[$j][0].' [PgroupID]: '.$Pgroup[$i]. ' [RightID]: ' . $group[$j][1]);
            echo('<br>');

    }



    
}
