<?php


    //connect to database
    //$mysqli = new mysqli("mariadb.cs.ut.ee", "sanderv_db", "B6jJrgrj8fem", "sanderv_db");

    $mysqli = new mysqli("localhost", "root", "", "Juhendid");
    
    if ($mysqli->connect_error){
        die("Connect error: " . $mysqli->connect_errno . ": " . $mysqli->connect_error);
    }



    $sql = "SELECT * FROM user WHERE name='Mihkel Mets'";
    $insert = $mysqli->query($sql);
    
    while ($row = mysqli_fetch_array($insert)){
        $authorId = $row['id'];
        $right = $row['right'];
        $authorDM = $row['department'];
        break;
    }

    $sql = "SELECT * FROM document WHERE state=2";
    $insert = $mysqli->query($sql);
    $newDocs = $insert->num_rows;
?>