%s
", $blogpost_addr, $title);
}
print_r("
");
for($i = 0; $i < count($tags); $i++) {
$tag = $tags[$i];
printf("
%s
", $tag["color"], $tag["name"]);
}
printf("
|
Published on: %s
|
%s
", date("Y-m-d", strtotime($date_posted)), $abstract);
}
/**
* Select all the blogposts from the database, their tags, then display them.
*/
function display_blog_previews($conn){
// Check DB connection
if($conn == null){
header($_SERVER["SERVER_PROTOCOL"]." 503 Service Unavailable", true, 503);
include_once($_SERVER["DOCUMENT_ROOT"]."/errors/503.php");
include_once($COMMONS."/footer.php");
die();
}
// Prepare statement for selecting all the blogposts
$stmt = $conn->prepare("SELECT blogpost_id, readable_address, title,
abstract, date_posted FROM blogposts ORDER BY date_posted DESC;");
// Execute the statement
$stmt->execute();
// Fetch the blogposts
$blogposts_arr = $stmt->fetchall(PDO::FETCH_ASSOC);
// Prepare new statement for selecting the tags for a given blogpost
$stmt = $conn->prepare("SELECT name, color FROM
blogpost_tags INNER JOIN blogpost_has_tag ON
blogpost_tags.tag_id = blogpost_has_tag.tag_id WHERE
blogpost_id = :blogpost_id;");
// Go through all the blogposts, fetch their tags and display them
for($i = 0; $i < count($blogposts_arr); $i++) {
// Get info for the current blog
$blog = $blogposts_arr[$i];
// Bind and execute the tag select
$stmt->bindParam(":blogpost_id", $blog["blogpost_id"]);
$stmt->execute();
// Fetch the tags
$tags_arr = $stmt->fetchall(PDO::FETCH_ASSOC);
// Display the blog
display_blog_preview($blog["blogpost_id"], $blog["readable_address"],
$blog["title"], $blog["abstract"], $blog["date_posted"],
$tags_arr);
}
}
display_header("Blogs");
?>
My blogposts
These can range from well thought out slow-burning blood-churning gems
to random brain farts in textual form, you can use tags to filter.
Recent blogposts get posted to
my atom feed.