I'm trying to build a simple pagination and the only thing that seems to work is the else statement, none of the if statements seem to work.
Here's what I have:
Code:
<?php if (journalsclass)
$db =& JFactory::getDBO();
$article =& JTable::getInstance('content');
$article->load(JRequest::getInt('id'));
$articleid = $article->id;
$author = $article->created_by;
$query = "SELECT id FROM #__content WHERE created_by = $author AND id < $articleid ORDER BY id desc LIMIT 1";
$db->setQuery( $query );
$previous = $db->loadResult();
$query = "SELECT id FROM #__content WHERE created_by = $author AND id > $articleid ORDER BY id asc LIMIT 1";
$db->setQuery( $query );
$next = $db->loadResult();
if ($previous < 1) {
$pagenav = "<span style='float:left; margin:0px 0px 0px 10px;'><a href='index.php?option=com_content&view=article&id=$previous&catid=16&Itemid=221&tmpl=component'>Next</a></span>"; }
if ($next < 1) {
$pagenav = "<span style='float:left; margin:0px 0px 0px 10px;'><a href='index.php?option=com_content&view=article&id=$previous&catid=16&Itemid=221&tmpl=component'>Previous</a></span>"; }
if ($next < 1 AND $previous < 1) {
$pagenav = "<span style='float:left; margin:0px 0px 0px 10px;'></span>"; }
else {
$pagenav = "<span style='float:left; margin:0px 0px 0px 10px;'><a href='index.php?option=com_content&view=article&id=$previous&catid=16&Itemid=221&tmpl=component'>Previous</a></span><span style='float:right; margin:0px 30px 0px 0px;'><a href='index.php?option=com_content&view=article&id=$next&catid=16&Itemid=221&tmpl=component'>Next</a></span>"; }
echo "<div class='journalnav' style='background:url(/images/journalbottom.png); height: 36px; width:473px;'>$pagenav</div>";
?>
I've tried several variation of isset(), empty(), and = null and nothing seems to work. I've also tried if elseif elseif else and that didn't work either, What am I doing wrong here?