use sqlite for collection information storage

this should be easier to extend than the multi dimensional php array
used before
This commit is contained in:
bsod 2020-11-10 23:25:09 +01:00
commit 5ffde76d5e
3 changed files with 69 additions and 28 deletions

View file

@ -1,42 +1,32 @@
<?php
$show_sep=true;
$db = new PDO('sqlite:projects_data/projects.db') or die('database error');
include('header.tpl');
?>
<div id="content_padding">
<?php
$collectionjs = file_get_contents("projects_data/collection_data.json");
$collection = json_decode($collectionjs, true);
?>
<div class="collection_container">
<?php
$index = 0;
foreach($collection as $c) {
$html = '
<div class="collection">
<div class="flexbox-col-img">
<div class="col-img-container">
<img class="col-image" src="projects_data/img/' . $c['preview_image_url'] . '" alt="example image for ' . $c['name'] .'">
<a class="col-img-desc" href="#">
</a>
</div>
<div class="col-desc">
' . $c['collection_description'] . '
foreach($db->query('select id, name, cover_image from collections;') as $c) {
$collection_id = $c['id'];
$cover_image = $c['cover_image'];
$collection_name = $c['name'];
print("
<div class='collection'>
<div class='flexbox-col-img'>
<div class='col-img-container'>
<a class='col-img-desc' href='show_collection.php?id={$collection_id}'>
<img class='col-image' src='projects_data/img/{$cover_image}' alt='example image for {$collection_name}'>
</a>
</div>
</div>
<h1>' . $c["name"] . '</h1>
<h1>{$collection_name}</h1>
</div>
';
}
print($html);
$index += 1;
");
}
?>
</div>
<!-- <section class="cta" style="clear: both;">
<div class="container">
<h2 class="title title-cta">Order your piece now!
</h2>
<a href="contacts.html" class="button button-dark">Order</a>
</div>
</section> -->
</div>
<?php include('footer.tpl'); ?>