<?php
    ob_start();
    require("db.php");
    $author = $_GET['author'];
?>
<!doctype html>
<html lang="en">
  <head>
      <!-- Global site tag (gtag.js) - Google Analytics -->
        <script async src="https://www.googletagmanager.com/gtag/js?id=G-9H2PTTEBRQ"></script>
        <script>
          window.dataLayer = window.dataLayer || [];
          function gtag(){dataLayer.push(arguments);}
          gtag('js', new Date());
        
          gtag('config', 'G-9H2PTTEBRQ');
        </script>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <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;
        }
      }
      
      .goback:hover {
          cursor: pointer;
      }
    </style>

  </head>
  <body>
      
      <?php 
        $str = "Steve Adcock";
        
        echo mysqli_real_escape_string($str);
      ?>
      
      <?php 

        if (($quoteId == ".php") || ($quoteId == "noQuoteId")) { ?>
            
            <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>
              <h1 class="display-5 fw-bold"></h1>
              <div class="col-lg-6 mx-auto">
                <p class="lead mb-4">That quote was not found in the database.</p>
              </div>
            </div>
            
        <?php } else {
            $quote = getQuoteByQuoteId($conn,$quoteId);
            $quoterow = $quote->fetchAll();
      ?>

            <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>
              <h1 class="display-5 fw-bold">Author name</h1>
            </div>
            
            <div class="row g-5">
                <div class="col-md-12 text-start">
                    <?php $relatedQuotes = getRelatedQuotesByQuote($conn,$row['quote']); ?> 
                    
                    <?php while ($row = $relatedQuotes->fetch())
                    { ?>
                        <div class="row text-start">
                            <div class="card">
                                <?php 
                                    $linkAuthor = str_replace(" ","-",$row['author']);
                                    $linkAuthor = str_replace("'","-",$linkAuthor);
                                    $linkAuthor = str_replace(".","",$linkAuthor);
                                ?>
                                <a class="quoteLink" href="quote/<?php echo $linkAuthor; ?>/<?php echo $row['id']; ?>">
                                    <div class="card-body">
                                        <h5 class="card-title"><?php echo $row['quote']; ?></h5>
                                    </div>
                                </a>
                                <div class="card-footer">
                                    <span class="badge bg-light text-dark"><a href="/search?authorExact=<?php echo $row['author']; ?>"><?php echo $row['author']; ?></a></span>
                                    <span class="badge bg-light text-dark">Filed in <a href="/search?topic=<?php echo $row['category']; ?>"><?php echo $row['category']; ?></a></span>
                                    <span class="badge bg-light text-dark cpyToClipboard" title="Copy to clipboard" quote="<?php echo $row['quote']; ?> -- <?php echo $row['author']; ?>" id="quote<?php echo $row['id']; ?>" onclick="copyToClipboard(this)">
                                        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-clipboard-plus" viewBox="0 0 16 16">
                                        <path fill-rule="evenodd" d="M8 7a.5.5 0 0 1 .5.5V9H10a.5.5 0 0 1 0 1H8.5v1.5a.5.5 0 0 1-1 0V10H6a.5.5 0 0 1 0-1h1.5V7.5A.5.5 0 0 1 8 7z"/>
                                        <path d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1v-1z"/>
                                        <path d="M9.5 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5h3zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3z"/>
                                      </svg>
                                    </span>
                                </div>
                            </div>
                        </div> <br />
                    <?php } // while ?>
                </div>
            </div>
    
        <?php } ?>

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