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:
parent
40a3b60bfb
commit
5ffde76d5e
3 changed files with 69 additions and 28 deletions
51
show_collection.php
Normal file
51
show_collection.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
$show_sep=true;
|
||||
$db = new PDO('sqlite:projects_data/projects.db') or die('database error');
|
||||
include('header.tpl');
|
||||
?>
|
||||
<div id="content_padding">
|
||||
<?php
|
||||
// get collection parameters
|
||||
$query = 'select id, name, description, cover_image from collections where id = :id';
|
||||
$col_query = $db->prepare($query);
|
||||
$col_query->bindParam(':id', $_REQUEST['id']);
|
||||
$col_query->execute();
|
||||
|
||||
$collection_info = $col_query->fetch();
|
||||
|
||||
// get collection items
|
||||
$query = 'select name, material, description, cover_image from collection_items where collection_id = :id';
|
||||
$ci_query = $db->prepare($query);
|
||||
$ci_query->bindParam(':id', $_REQUEST['id']);
|
||||
$ci_query->execute();
|
||||
?>
|
||||
|
||||
<h1>
|
||||
<? print($collection_info['name']); ?>
|
||||
</h1>
|
||||
<section class="description">
|
||||
<? print($collection_info['description']); ?>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div class="ci_container">
|
||||
<?php
|
||||
foreach($ci_query->fetchAll() as $ci) {
|
||||
if ($ci['cover_image'] == null) {
|
||||
$ci['cover_image'] = $collection_info['cover_image'];
|
||||
}
|
||||
$ci_img_url = 'projects_data/img/' . $ci['cover_image'];
|
||||
print("
|
||||
<div class='collection-item'>
|
||||
<img src='{$ci_img_url}' alt='Cover picture of {$ci['name']}' />
|
||||
<h1>{$ci['name']}</h1>
|
||||
</div>
|
||||
");
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?
|
||||
include('footer.tpl');
|
||||
$db = null;
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue