flash.moe/public/collection/index.php

65 lines
1.9 KiB
PHP
Raw Normal View History

2020-08-20 00:02:37 +00:00
<?php
require_once '_inc.php';
$getSystems = $pdo->prepare('
SELECT s.*, (
SELECT COUNT(`game_id`)
FROM `col_games`
WHERE `sys_id` = s.`sys_id`
) AS `sys_games`,
(
SELECT COUNT(`game_id`)
FROM `col_games_ownership`
WHERE `game_id` IN (
SELECT `game_id`
FROM `col_games`
WHERE `sys_id` = s.`sys_id`
)
) AS `sys_games_owned`
FROM `col_systems` AS s
ORDER BY `sys_games_owned` DESC
');
$getSystems->execute();
$systems = $getSystems->fetchAll(PDO::FETCH_OBJ);
$systems = [
-1 => (object)[
'sys_id' => 0,
'sys_short' => 'all',
'sys_name' => 'All Games',
'sys_link' => 'games.php',
],
] + $systems;
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Game Collection</title>
<link href="assets/style.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="wrapper">
<h1><a href="./">Game Collection</a></h1>
<div class="syscont">
<?php
foreach($systems as $system):
if(isset($system->sys_games) && $system->sys_games < 1)
continue;
?>
<div class="sysbox">
<img src="<?=sprintf('assets/systems/%s.jpg', $system->sys_short);?>" alt="" class="sysbox-bg"/>
<a class="sysbox-link" href="<?=($system->sys_link ?? sprintf('games.php?sys=%d', $system->sys_id));?>"></a>
<div class="sysbox-cont">
<h2><?=$system->sys_name;?></h2>
<?php if(isset($system->sys_games)): ?>
<p><?=number_format($system->sys_games_owned);?> of <?=number_format($system->sys_games);?> game<?=($system->sys_games !== 1 ? 's' : '');?></p>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</body>
</html>