Skip to content

Instantly share code, notes, and snippets.

@stefthoen
Forked from rutger1140/list.php
Created November 18, 2013 16:36
Show Gist options
  • Save stefthoen/7530946 to your computer and use it in GitHub Desktop.
Save stefthoen/7530946 to your computer and use it in GitHub Desktop.
<?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