Location: PHPKode > projects > Phpfastnews > article_index.php
<?php
/*	Copyright (c) 2001-02 by Ken Williams (hide@address.com)*/
/*	http://phpfastnews.sourceforge.net/ & http://www.phpfastnews.com*/
/*								        */
/*	You can redistribute and/or modify the following code under the */
/*	terms of the GNU General Public License as published by the	*/
/*	the Free Software Foundation.					*/
/*									*/
/*	All code by Ken Williams (HDwebdev) unless otherwise noted	*/
/* This is an alpha test release -- not intended for live site	use	*/

$pg = "article_index";
$tpl = "article.tpl";
require('Lib/prependphpfn.php');

$r->set_block('TPL','ARTICLE_INDEX');

$r->set_block('ARTICLE_INDEX', 'ARTICLESECTION', 'section');
$r->set_block('ARTICLESECTION', 'ARTICLECATEGORY', 'category');
$r->set_block('ARTICLECATEGORY', 'ARTICLES', 'articles');

$db1 = newObject('Core::psDb'); $db2 = newObject('Core::psDb'); $db3 = newObject('Core::psDb');

$query="select name,topic_id from fn_atopics where parent_id = '0'";
$db3->query($query);
 
while ($db3->next_record()) {
	$r->set_var('SECTION',$db3->f("name"));

	$section_id = $db3->f("topic_id");
	$query = "select name,topic_id from fn_atopics where parent_id = '$section_id'";
	$db2->query($query);
	while ($db2->next_record())	{
		$r->set_var('CATEGORY',$db2->f("name"));
		$topic_id = $db2->f("topic_id");
		$query = "select subject,article_id,replies from fn_article where topic_id = '$topic_id'";
		$db1->query($query);

		while ($db1->next_record())	{
			$r->set_var("LNK", "article_view.php?r_id=" . $db1->f("article_id"));
			$r->set_var("ARTICLE", $db1->f("subject"));
			$cnt = $db1->f("replies");
			if ($cnt)
				{
				$r->set_var("REPLYS", "(" . $cnt . " comments)");
				}
				else
				{
				$r->set_var("REPLYS", '');
				}
			$r->parse('articles', 'ARTICLES',true);
			}
		$r->parse('category','ARTICLECATEGORY',true);
		}
	$r->parse('section','ARTICLESECTION',true);
}

$r->parse('body','ARTICLE_INDEX',true);
require('Lib/appendphpfn.php');
?>
Return current item: Phpfastnews