Skip to content

Instantly share code, notes, and snippets.

@samroar
Created July 19, 2014 19:42
Show Gist options
  • Select an option

  • Save samroar/4b210eec7f248d6539cc to your computer and use it in GitHub Desktop.

Select an option

Save samroar/4b210eec7f248d6539cc to your computer and use it in GitHub Desktop.
<!doctype HTML>
<html>
<head>
<title>reddit: the front page of the internet</title>
<link href="reddit.css" rel="stylesheet"/>
<script src ="reddit.js" type="text/javascript"></script>
</head>
<body>
<?php
$dbh = new PDO('mysql:host=localhost;dbname=reddit','root',"");
$rows = $dbh->query("SELECT id, title, user, subreddit, url, timestamp from posts");
foreach($rows as $row) { ?>
<div class="container">
<h2 class="title">
<a href="http://localhost/reddit/post.php?id=<?php echo $row['id']; ?>"> <?php echo $row['title']; ?></a>
</h2>
<div class="info">
submitted <?php echo $row['timestamp']; ?> by <?php echo $row['user']; ?> to <?php echo $row['subreddit']; ?>
</div>
</div>
<?php }
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment