<!doctype html>
<?php
    // set variables to hold data
    $TeamID = 0; //0 means new thingy
    $TeamName = "";
    $GameID = "";

     //connect to db
     $dbconn = mysqli_connect("localhost", "root", "", "gcsowls");
     if ($dbconn->connect_error > 0) {
         die('Could not connect: ' . $dbconn->connect_error);
         exit(); // you should redirect to some form of error page !!!!
     }
        //need info from Games just to display
        $gamesResult =  mysqli_query($dbconn, "SELECT GameID, GameName  FROM games ORDER BY GameID" );
        $gameArray = array();
        $dropdown = "";
    
    
        if (mysqli_num_rows($gamesResult) > 0) {
            // output data of each row
            while($row = mysqli_fetch_assoc($gamesResult)) {
              $id = $row['GameID'];
              $gameName = $row['GameName'];
    
             $gameArray += array($id => $gameName );
            }
        } else {
            echo "0 results";
          }
          foreach ($gameArray as $key => $value) {
            //we are building the option thingy
            $dropdown .= "<option value='$key'>$value</option>";
          }
    
?>

<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <meta name="description" content="">
        <meta name="author" content="HND Applied Computing">
        <meta name="generator" content="Jekyll v3.8.5">
        <title>Media Rental 2021</title>  

        <!-- include any relevant css/js files -->
        <?php include "../template/pageheader.php"; ?>

    </head>
    <body>
        <!-- include the top menu -->
        <?php include "../template/topmenu.php"; ?> 
        <!-- end top menu -->

        <div class="container-fluid">
            <div class="row">
                <!-- insert the side menu -->
                <?php include "../template/sidemenu.php"; ?>	
                <!-- end side menu -->

                <!-- webpage content goes here -->
                <main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-4">
                  <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
                        <h1 class="h1">Create Team</h1> 
                  </div>
                    <div class="col-md-8 order-md-1">
                        <?php include "addedit.php" ?>
                    </div>
                </main>
            </div>
        </div>

        <!-- include any relevant js files -->
        <?php include "../template/pagefooter.php"; ?>

    </body>
</html>
