Created
November 18, 2013 16:36
-
-
Save rutger1140/7530936 to your computer and use it in GitHub Desktop.
List urls from Mathias Bynens URL shortener in a simple table. https://github.com/mathiasbynens/php-url-shortener
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require('config.php'); | |
$db = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE); | |
$db->set_charset('utf8'); | |
$result = $db->query('SELECT *, DATE(redirect.date) AS shortdate FROM redirect ORDER BY redirect.date DESC'); | |
// If we have no results | |
if ($result && $result->num_rows < 0) die('No results'); | |
?><!doctype html> | |
<meta charset="utf-8"> | |
<title>list</title> | |
<style> | |
html { | |
font-size: 100%; | |
-webkit-text-size-adjust: 100%; | |
-ms-text-size-adjust: 100%; | |
font-family: sans-serif; | |
} | |
body { margin: 0; } | |
a:focus { outline: thin dotted; } | |
a:hover, a:active { outline: 0; } | |
table { | |
border: 1px solid #6f7072; | |
border-collapse: collapse; | |
margin: 1em auto; | |
width: 95%; | |
} | |
th,td { | |
border: 1px solid #ccc; | |
padding: .5em; | |
font-size: .875em; | |
} | |
th { | |
background-color:#6f7072; | |
color: #fff; | |
} | |
th:first-child { | |
width: 6em; | |
} | |
a { | |
word-break: break-word; | |
} | |
</style> | |
<table> | |
<thead> | |
<tr> | |
<th>added</th> | |
<th>slug</th> | |
<th>url</th> | |
<th>hits</th> | |
</tr> | |
</thead> | |
<tbody> | |
<?php while($row = $result->fetch_object()) : ?> | |
<tr> | |
<td><?php echo $row->shortdate; ?></td> | |
<td><?php echo $row->slug; ?></td> | |
<td><a href="<?php echo htmlentities($row->url); ?>"><?php echo htmlentities($row->url) ?></a></td> | |
<td><?php echo $row->hits; ?></td> | |
</tr> | |
<?php endwhile; ?> | |
</tbody> | |
</table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment