Location: PHPKode > projects > News Manager - RSS aggregator > newsmanager/allnews_qry.php
<?php
	/*******************************************************************************
     **  File          :  alllnews_qry.php                                        **
     **  Author        :  G.Ramkumar                                              **
     **  Description   :  Dispalying all news section Query usedd in XML services **
  	 **  Date          :  14/09/2005                                              **
     **  Last Modified :  14/09/2005                                              **
     **  PHP Version   :  5.0.3                                                   **
     **                                                                           **
     *******************************************************************************/
  $comdate=date("Y-m-d")." ".date("H:i:s");

  $tot_exist_id=$comp_id.$comp_id_r;

  if($tot_exist_id!=""){
    $tot_exist_id=trim($tot_exist_id,",");
    $all_item_S="where newsitem_id not in (".$tot_exist_id.")";
   }

 if($_REQUEST['cat_id']!="" && $_REQUEST['subcat_id']=="")
 {
    if($all_item_S!="")
       $all_catid ="and category_id=".$_REQUEST['cat_id'];
     else
       $all_catid ="where category_id=".$_REQUEST['cat_id'];
 }elseif($_REQUEST['cat_id']!="" && $_REQUEST['subcat_id']!="")
 {
   if($all_item_S!="")
     $all_catid ="and subcategory_id=".$_REQUEST['subcat_id'];
   else
     $all_catid ="where subcategory_id=".$_REQUEST['subcat_id'];
 }
 else{
        $new_cat_qry="select * from category where language='$lang'";
	    $new_cat_res=$pg_sql->query_pass($new_cat_qry,"4");

	    $new_subcat_qry="select * from subcategory where language='$lang'";
	    $new_subcat_res=$pg_sql->query_pass($new_subcat_qry,"4");

	    for($y=0;$y<count($new_cat_res);$y++)
	    {
	      $N_catid .=$new_cat_res[$y][category_id].",";
	    }
	    for($z=0;$z<count($new_subcat_res);$z++)
		{
	           if($new_subcat_res[$z][subcategory_id]!="")
		          $N_subcatid .=$new_subcat_res[$z][subcategory_id].",";
	    }
	    $N_catid=trim($N_catid,",");


	    if($N_subcatid!="")
	    {
	       $N_subcatid=trim($N_subcatid,",");
	       $N_qry = " or subcategory_id in (".$N_subcatid.")";
	    }
	    if($N_catid!="")
	    {
	       if($all_item_S!="")
	         $all_catid="and category_id in (".$N_catid.")". $N_qry ;
	       else
	         $all_catid="where category_id in (".$N_catid.")". $N_qry ;
    }
 }


$allnewsqry="select DISTINCT(newsitem_id),pubdate from newsitem_category $all_item_S $all_catid order by pubdate desc limit 15";

$allnews_res=$pg_sql->query_pass($allnewsqry,"4");
$all_cnt_=count($allnews_res);

for($b=0;$b<$all_cnt_;$b++)
{
    $xml_allnewsid=$allnews_res[$b][newsitem_id];

    $xml_all_news="select * from rssurl_newsitem where url_newsitem_id=$xml_allnewsid and frontend_export='Y' and language='$lang'";
    $xml_all_news_res=$pg_sql->query_pass($xml_all_news,"4");

	$xml_all_new_news="select * from new_newsitem where newsitem_id=$xml_allnewsid and frontend='Y' and language='$lang'";
	$xml_all_new_news_res=$pg_sql->query_pass($xml_all_new_news,"4");

	if($xml_all_news_res[0]['url_newsitem_id']!="")
	{
	   $xml_all_news_res[0]['url_newsitem_id']."<br>";
	   $xml_allid .=$xml_all_news_res[0]['url_newsitem_id'].",";

	   $xml_cnt_[]=$xml_all_news_res[0]['url_newsitem_id'];

	}
	if($xml_all_new_news_res[0]['newsitem_id']!="")
	{
	  $xml_allid_new .=$xml_all_new_news_res[0]['newsitem_id'].",";
	  $xml_cnt_[]=$xml_all_new_news_res[0]['newsitem_id'];


    }

}

$tot_all_news__=$xml_allid_new.$xml_allid.$tot_exist_id;


?>
Return current item: News Manager - RSS aggregator