necrobyter
Members
-
Joined
-
Last visited
Reputation Activity
-
necrobyter got a reaction from troyfawkes in How to separate my html from my database php functionsI don't think that you necessarily need to OO a simple piece of code.
Functional programming is often easier to read functional code but the key here is how you return it.
$images=""; if ($numRows > 0){ $count=0; while ($row = mysql_fetch_assoc($query)) { $thumbnail="images/assets/".$row['thumbnail_image']; $images[$count]=$thumbnail; } } return $images; }
Then when you call $images=getPortfolioPieces(); you'll end up with an array of image locations.
Then when you want to display them you simply insert:
<?php foreach ($images as $i){ echo "<img src='$i' />"; } ?>
It's true that using MVC frameworks will properly separate, data / design and output and that this is a good thing, so is OO but if it's a quick and easy solution you want, traditional functional or even procedural can get the job done and is, in my humble opinion, easier to digest / debug and just gets the job done.
I never have liked MVC frameworks, I do sometimes use my own for large scale systems, but it depends on how long you have to get the job done and whether it's appropriate or not.