<?php
    require("db.php");
    $total = getTotalQuotes($conn);
    $randomQuote = getRandomQuote($conn);
    $quote = $randomQuote->fetchAll();
?>
<!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>
    <?php foreach($quote as $row) { ?>
      <h1 class="display-5 fw-bold"><?php echo $row['quote']; ?></h1>
      <div class="col-lg-6 mx-auto">
        <p class="lead mb-4">-- <?php echo $row['author']; ?></p>
      </div>
    <?php } ?>
    </div>

    <div class="row g-5">
      <div class="col-md-6 text-start">
        <h2>Search the database</h2>
        <p>
            Search the largest database of the best money quotes. <span class="badge bg-primary"><?php echo $total; ?> Quotes</span>
        </p>
        <form class="row g-3" action="/search">
          <div class="col-md-6">
            <input type="text" class="form-control" id="author" name="author" placeholder="Author">
          </div>
          <div class="col-md-6">
            <select class="form-select" name="topic">
                <option value="">-- Any Topic --</option>
                <option value="Debt">Debt</option>
                <option value="Investing">Investing</option>
                <option value="Humor">Humor</option>
                <option value="Inspirational">Inspirational</option>
                <option value="Minimalism">Minimalism</option>
                <option value="Money">General Money</option>
            </select>
          </div>
          <div class="col-12">
            <input type="text" class="form-control" id="keywords" name="keywords" placeholder="Keywords...">
          </div>
          <div class="col-12">
            <button type="submit" class="btn btn-primary">Search the database</button>
          </div>
        </form>
      </div>

      <div class="col-md-6 text-start">
        <h2>About Today's Money Quote</h2>
        <p><strong>Today's Money Quote</strong> is a project aimed at compiling the biggest searchable database of the best money quotes. As of today, we are keeping track of <?php echo $total; ?> different quotes about money.</p>
        <ul class="icon-list">
          <li>Popular topics: <a href="/search?topic=Debt">Debt</a>, <a href="/search?topic=Humor">Humor</a>, <a href="/search?topic=Investing">Investing</a>, <a href="/search?topic=Money">General Money</a></li>
          <li>Or, browse <a href="/search?all=true">all <?php echo $total; ?> quotes we're tracking</a> in the database</li>
          <li>Quotes from: <a href="/search?authorExact=Warren%20Buffett">Warren Buffett</a>, <a href="/search?authorExact=Benjamin%20Franklin">Benjamin Franklin</a> and more</li>
          <li><a href="/byAuthor">Browser through all quotes by author</a></li>
        </ul>
      </div>
      
      <div class="container">
          <h2>Browse the top money quotes</h2>
          <div class="row">
            <div class="col text-center">
                <a href="/search?authorExact=Warren%20Buffett"><img src="/img/warren-buffett.jpg" alt="Warren Buffett" width="150" /></a><br />
                <a href="/search?authorExact=Warren%20Buffett">Warren Buffett</a>
            </div>
            <div class="col text-center">
                <a href="/search?authorExact=Suze%20Orman"><img src="/img/suze-orman.jpg" alt="Suze Orman" width="150" /></a><br />
                <a href="/search?authorExact=Suze%20Orman">Suze Orman</a>
            </div>
            <div class="col text-center">
                <a href="/search?authorExact=Ramit%20Sethi"><img src="/img/ramit-sethi.jpg" alt="Ramit Sethi" width="150" /></a><br />
                <a href="/search?authorExact=Ramit%20Sethi">Ramit Sethi</a>
            </div>
            <div class="col">
                <a href="/search?authorExact=Naval%20Ravikant"><img src="/img/naval-ravikant.jpg" alt="Naval Ravikant" width="150" /></a><br />
                <a href="/search?authorExact=Naval%20Ravikant">Naval Ravikant</a>
            </div>
            <div class="col">
                <a href="/search?authorExact=James%20Clear"><img src="/img/james-clear.jpg" alt="James Clear" width="150" /></a><br />
                <a href="/search?authorExact=James%20Clear">James Clear</a>
            </div>
            <div class="col">
                <a href="/search?authorExact=Dave%20Ramsey"><img src="/img/dave-ramsey.jpg" alt="Dave Ramsey" width="150" /></a><br />
                <a href="/search?authorExact=Dave%20Ramsey">Dave Ramsey</a>
            </div>
          </div>
      </div>
      
    </div>

    <?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>
