Location: PHPKode > projects > Jarida > jarida_1.0/index.php
<?php
include("header.php");

//Get a limit of articles for display in the front page
$query = "SELECT article_id FROM tblArticle ORDER BY article_id DESC LIMIT " . $config['num_articles'];

$result = $db->doQuery($query);

while($row = $result->getArray())
{
  $article = new Article($db, $row['article_id']);
  $article->setBody(replaceSmilies($article->getBody(), $db));

  $query2 = "SELECT photo_filename FROM tblArticlePhoto WHERE photo_article_id = " . $article->getId();
  $photo_file = "";
  if($result2 = $db->doQuery($query2))
    {
      if($result2->getNumRows() > 0)
	{
	  $row2 = $result2->getArray();
	  $photo_file = "./img/upload/" . $row2['photo_filename'];
	  $dimensions = getimagesize($photo_file);
	  if(($dimensions[0] > 300) OR ($dimensions[1] > 300))
	    {
	      $dimensions2 = imageResize($dimensions[0], $dimensions[1], 300);
	    }
	  else
	    {
	      $dimensions2 = array('width' => $dimensions[0],
				   'height' => $dimensions[1]);
	    }
	}
    }
  $articles[] = array('id' => $article->getId(),
		      'title' => $article->getTitle(),
		      'body' => $article->getBody(),
		      'numComments' => $article->getNumComments(),
		      'photo_file' => $photo_file,
		      'dimensions' => $dimensions2,
		      'date' => $article->getDate());		      
}

$template->assign('articles', $articles);

$template->display($config['theme'].'/index.tpl');

include("footer.php");

?>
Return current item: Jarida