<?php

$author = 'Anonymous';

function displayPost($sqlOutput, $external)
{
    global $author;
?><DIV CLASS="post" ID="post-<?php echo($sqlOutput['id']); ?>"><DIV CLASS="post-title"><?php
    if ($external)
    {
?><A HREF="read.php?id=<?php echo($sqlOutput['id']); ?>"><?php
    }
    echo($sqlOutput['title']);
    if ($external)
    {
?></A><?php
    }
?></DIV><DIV CLASS="post-data">Posted by <STRONG><?php echo($author); ?></STRONG><?php
    if ($sqlOutput['tags'] != '')
    {
        if (strpos($sqlOutput['tags'],',') !== FALSE)
        {
            $tagArr = split(',',$sqlOutput['tags']);
?> with the tags <?php
            $i=0;
            while ($i < count($tagArr))
            {
                $tag = $tagArr[$i];
?><STRONG><A HREF="tag.php?tag=<?php echo($tag); ?>"><?php echo($tag); ?></A></STRONG><?php
                if ($i < (count($tagArr)-2))
                {
                    echo(',');
                } else if ($i == (count($tagArr)-2))
                {
                    echo(' and ');
                }
                $i++;
            }
        } else {
?> with the tag <STRONG><A HREF="tag.php?tag=<?php echo($sqlOutput['tags']); ?>"><?php echo($sqlOutput['tags']); ?></A></STRONG><?php
        }
    }
?> on <?php echo(date('F jS Y h:m:s A',strtotime($sqlOutput['pubDate']))); ?></DIV><DIV CLASS="post-text"><?php
    if ($external)
    {
        echo(nl2br(substr($sqlOutput['text'],0,500)));
        if (strlen($sqlOutput['text']) > 500)
        {
?>....<P><A HREF="read.php?id=<?php echo($sqlOutput['id']); ?>">Click here for the rest of this post</A><?php
        }
    } else {
        echo(nl2br($sqlOutput['text']));
    }
?></DIV></DIV><P><?php
}

?>