I’m building a site to display my comics- but I’ve read some tutorials (Elated.com CMS design with images) that advocate for using the database to store the file extensions, and use a more object oriented approach. I’m not doing that as of right now because I didn’t see the need, as I manage files through FTP, and users won’t be adding content. So, before I continue I’d like some peace of mind that my current architecture is okay.
Right now, My pages get images from the filesystem as such:
<?php
$dir = "../images/*";
foreach(glob($dir) as $image) {
$total = count(glob($dir . "*"));
?>
<span class="comicBG"><a href="./viewComic.php?image=<?php echo $image ?>"><img src="./thumbnailer.php?img=<?php echo $image ?>&mw=&mh=" /></a></span>
<?php } ?>
Clicking on a comic displays that comic on a template:
<?php $myImage = $_GET['image']; ?>
<center><img src="<?php echo $myImage ?>" /></center>
Can I continue on this way?
Thank you
You can definitely start that way but I guess it all depends on what your end goal is. If you simply want to be able upload your comics to the /images/ directory and have the script display thumbnails and links, then you are good… but if you think you’ll ever want more functionality than I would recommend at least working from a database. For example it would be quite easy to store information about how many times each comic thumbnail was clicked on, or perhaps the screen resolutions of the people visiting and looking at the comics so you can then adjust the size of your comics accordingly. Just a couple of ideas, but might be worth your time.
EDIT: Here is a sample table structure just to give you some ideas to start with.
You could get fancy and setup a second table that you insert the view information into (date, time, ip_address, comic, etc) and could generate some fairly interesting stats.
Sample data would like the following:
Could go on and on but I think you get the point.