<?php
    require("db.php");
    $getRows = getQuoteCountByAuthor($conn);
?>
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
    <title>Today's Money Quote :: The biggest collection of money quotes on the planet</title>

    <!-- Bootstrap core CSS -->
    <link href="/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <link href="/css/styles.css" rel="stylesheet">

    <!-- Favicons -->
<link rel="apple-touch-icon" href="/img/moneyquoteslogo.png" sizes="180x180">
<link rel="icon" href="/img/moneyquoteslogo.png" sizes="32x32" type="image/png">
<link rel="mask-icon" href="/img/favicons/safari-pinned-tab.svg" color="#7952b3">
<meta name="theme-color" content="#7952b3">

<style>
      .bd-placeholder-img {
        font-size: 1.125rem;
        text-anchor: middle;
        -webkit-user-select: none;
        -moz-user-select: none;
        user-select: none;
      }

      @media (min-width: 768px) {
        .bd-placeholder-img-lg {
          font-size: 3.5rem;
        }
      }
    </style>

  </head>
  <body>

<div class="container-fluid text-center">
    <div class="px-4 py-5 my-5">
      <a href="/"><img class="d-block mx-auto mb-4" src="/img/moneyquoteslogo.png" alt="Today's Money Quote" width="52" height="52"></a>
    </div>

    <?php
        $total = $getRows->rowCount();
        $rows = $getRows->fetchAll();
    ?>

    <div class="row g-5">
      <div class="col-md-12 text-start">
        <h2>
            Browse all quotes by Author (<?php echo $total; ?>)
        </h2>
        To quickly search through this table, use Command (on Mac) or Ctrl (on Windows) + f. 
    </div>

    <div class="row">
        <table class="table">
          <thead>
            <tr>
              <th scope="col">Author</th>
              <th scope="col"># of Quotes</th>
            </tr>
          </thead>
          <tbody>
            <?php foreach($rows as $row) { ?>
            <tr>
              <td class="text-start"><?php echo $row['author']; ?></td>
              <td><a href="/search?authorExact=<?php echo $row['author']; ?>"><?php echo $row['Count']; ?></a></td>
            </tr>
            <?php } ?>
          </tbody>
        </table>
    </div>

    <br />

    <?php include("inc.footer.php"); ?>

</div> <br />

<script src="/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
  </body>
</html>
