<?php
require 'includes/process.php';
?>

<div class="container">
    <div class="row justify-content-center">
      <form action="" method="POST" enctype="multipart/form-data">
            <input type="hidden" name="id" value="<?php echo $id; ?>">
                <div class="form-group">
                  <input type="text" name="fname" class="form-control" placeholder="Enter Text" Required>
                </div>
                <div class="form-group">
                  <label>Select Image</label>
                  <input type="file" name="image" Required>
                </div>
                <div class="form-group">
                    <button  type="submit" class="btn btn-primary" name="submit">Submit</button>
                </div>
        </form>
    </div>

    <div class="row justify-content-center">
      <table class="table">
        <tr>
          <td>Image</td>
          <td>Description</td>
          <th colspan="2">Action</th>
        </tr>
          <?php //selects all recordsd from the table / izvēlas visus datubāzes ierakstus
              $records = $conn->query("SELECT * FROM gallery") or die($mysqli->error()); 
              while ($row = $records->fetch_assoc()):
            ?>
              <tr> <!--outputs images & fname to website / izvada bildes un apraksta laukus mājaslapā-->
               <td><img src="<?php echo $row['images']; ?>" ></td>
                <td><?php echo $row['fname']; ?></td>
                <td> <a href="includes/process.php?delete=<?php echo $row['id'];?>" class="btn btn-danger">Delete</a> </td>
              </tr>	
            <?php
            endwhile;
          ?>
      </table>
    </div>
</div>