Location: PHPKode > scripts > Create Your Own Directory > cms/functions/newlyadded.php
<html>
<?php
  $home="../";
  include "$home/header.php";
  $sub=$_GET['sub'];
?>
<?php
  $str="select id,name,des from type where parentid=0";
  $result = mysql_query($str);
?>
  <table width=80% border=0 align=center>
    <tr><td class=heading   align=center>
    <?php
    if($sub=="rated")
    {
	echo"HIGHLY RATED CONTENT";
    }else if($sub=="visited")
    {
      echo"MOST VISITED CONTENT";
    }else if($sub=="new")
    {
	echo"NEWLY ADDED CONTENT";
    }
    ?>
    </td></tr>
    <tr><td height=15></td></tr>
    
	  <?php
	    $idarr=Array();
	    $namearr=Array();
 	    $k=0;
          while($row = @mysql_fetch_array($result, MYSQL_ASSOC))
	    {
	      $id=$row['id'];
            $name = $row['name'];      
	      $des = $row['des'];
	      $idarr[$k]=$id;
	      $namearr[$k]=$name;
	      $k=$k+1;
	   
          }
       //print_r($namearr);
	?>
  
    <tr><td>
	<?php
	$cat = Array();
	$size=count($idarr);
  for($i=0;$i<$size;$i++)
  {
   $str="select id,parentid,name from type";
   $result = mysql_query($str);
	while($line = @mysql_fetch_array($result, MYSQL_ASSOC))
	{
	  $id=$line['id'];
	  $parentid=$line['parentid'];
	  $name=$line['name'];
	  $cat[$j] =Array($id, $parentid,$name);
	  $j=$j+1;
	}
	  $j=0;
	  $check = 'true';
	  $val =$idarr[$i];
	  $arr =Array();
	  $jj=0;
	  $cnt=count($cat);
      for($ff=0; $ff<=$cnt; $ff++)
	{
	  if($cat[$ff][1]==$val)
	  {
	    $arr[$ff]=$cat[$ff][0];
        }
	}
      $str=implode(',',$arr);
	$qstr=Array();
	$qry="select id from type where parentid in (select id from type where  parentid in ($str))
	union select id from type where  parentid in ($str)";
	//echo"$qry";
	$res=mysql_query($qry);
	$j=0;
	while($line = @mysql_fetch_array($res, MYSQL_ASSOC))
	{
	  $qstr[$j]=$line['id'];
	  $j++;
	}
	  $str=implode(',',$qstr);
	if($str!="")
      {
	  echo"<br><strong>$namearr[$i]</strong><br><br>";
      }
	  echo"<table bgcolor=#dedede border=0 cellspacing=0 cellpadding=0 width=100%>";
     
	if($sub=="rated" && $str!="")
	{
		$qry="select tid,cntid,adddate,contents,B.rateval from cnt left join (select rid,sum(rateval) as rateval from  rating group by rid)B on(cnt.cntid=B.rid) where tid in ($str) order by rateval desc limit 10"; 
		if($typ[18]=="updated"){
			echo"<tr bgcolor=#dedede ><td class=heading1 width=20%  align=center background=".$home."includes/print.php?cnt=".$id[18]." height=".$uheight[18]."border=0>ADDED DATE</td><td  class=heading1  background=".$home."includes/print.php?cnt=".$id[18]." height=".$uheight[18]." width=70%  border=0 align=center>TITLE
			</td><td class=heading1 background=".$home."includes/print.php?cnt=".$id[18]." height=".$uheight[18]." width=10%   border=0 align=center>RATING</td></tr>";
	    		
		}else{
			 echo"<tr bgcolor=#dedede ><td  width=20%  background=".$home."image/img18.gif height=".$height[18]." border=0 class=heading1 align=center>ADDED DATE</td><td align=center class=heading1 width=70%  background=".$home."image/img18.gif  height=".$height[18]." border=0>TITLE
			</td><td background=".$home."image/img18.gif  height=".$height[18]." width=10%  border=0 class=heading1 align=center>RATING</td></tr>";
   		
            }

	}
	if($sub=="visited" && $str!="")
	{
	 $qry="select tid,cntid,adddate,contents,view from cnt  where tid in ($str) order by view desc limit 10";

	 if($typ[18]=="updated"){
			echo"<tr bgcolor=#dedede ><td class=heading1 align=center background=".$home."includes/print.php?cnt=".$id[18]." height=".$uheight[18]." width=20% border=0>ADDED DATE</td><td  class=heading1 width=70% background=".$home."includes/print.php?cnt=".$id[18]." height=".$uheight[18]." align=center>TITLE
			</td><td class=heading1 width=10% background=".$home."includes/print.php?cnt=".$id[18]." height=".$uheight[18]." align=center>VIEWS</td></tr>";
	    		
		}else{
			 echo"<tr bgcolor=#dedede ><td width=20% background=".$home."image/img18.gif height=".$height[18]." border=0 class=heading1 align=center>ADDED DATE</td><td align=center class=heading1 background=".$home."image/img18.gif height=".$height[18]." width=70% border=0>TITLE
			</td><td background=".$home."image/img18.gif height=".$height[18]." width=10% border=0 class=heading1 align=center>VIEWS</td></tr>";
 
	 }
    }
	else if($sub=="new" && $str!="")
	{
	  $qry="select tid,cntid,adddate,contents,cntid,B.rateval from cnt left join (select rid,sum(rateval) as rateval from  rating group by id)B on(cnt.cntid=B.rid) where tid in ($str)  and (DATEDIFF(sysdate(),adddate) <=10) limit 10";
	  if($typ[18]=="updated"){
			echo"<tr bgcolor=#dedede ><td class=heading1 width=20%  align=center background=".$home."includes/print.php?cnt=".$id[18]." height=".$uheight[18]." border=0>ADDED DATE</td><td  class=heading1 width=70%  background=".$home."includes/print.php?cnt=".$id[18]." height=".$uheight[18]."  border=0 align=center>TITLE
			</td><td width=10% class=heading1 background=".$home."includes/print.php?cnt=".$id[18]." height=".$uheight[18]." border=0 align=center>RATING</td></tr>";
	    		
		}else{
			 echo"<tr bgcolor=#dedede ><td background=".$home."image/img18.gif height=".$height[18]." width=20% border=0 class=heading1 align=center>ADDED DATE</td><td align=center class=heading1 background=".$home."image/img18.gif height=".$height[18]." width=70% border=0>TITLE
			</td><td background=".$home."image/img18.gif height=".$height[18]." width=10% border=0 class=heading1 align=center>RATING</td></tr>";

	   }
    }
	//echo"$qry";
	$res=mysql_query($qry);
	while($line = @mysql_fetch_array($res, MYSQL_ASSOC))
	{
     	  $tid=$line['tid']	  ;
        $cntid=$line['cntid'];
	  $date=$line['adddate'];
	  $contents=$line['contents'];
	  $rateval=$line['rateval'];
	  $view=$line['view'];
 	  $arr=split('####',$contents);
	  if($sno%2 == 0)
			$col = "#fffde9";
		else
			$col = "#e9f7fe";
	  $str="select a.name as parent,B.name as child1,C.name as child2  from type a left join (select id,name,parentid from type ) B on (a.id=B.parentid) left join (select id,name,parentid from type )C on( B.id=C.parentid) where C.id=$tid";
	  
	  //echo"$str<br>";
		$result=mysql_query($str);
		
	      while($row=mysql_fetch_array($result,MYSQL_ASSOC))
		{
		$linkparent=$row['parent'];
     		$linkchild1=$row['child1'];
		$linkchild2=$row['child2'];
		}
		$lkchild1=str_replace(" ","_","$linkchild1");
		$lkchild2=str_replace(" ","_","$linkchild2");
		$title1=str_replace(" ","_","$arr[0]");
	      $urlarr=array("$linkparent","$lkchild1","$title1");
	      $urlarr1=implode('/',$urlarr);
            //echo"$urlarr1";
	if($sub=="rated" || $sub=="new")
	{
	  if($str!="")
	  {

	    echo"<tr class=heading1 bgcolor=$col height=20><td align=center>$date</td><td align=center><a href='$urlarr1-$cntid.html'>$arr[0]</a></td><td align=center>$rateval</td></tr>";
	  }
	}else if($sub=="visited")
	{
	  if($str!="")
	  {
	    echo"<tr class=heading1 height=20 bgcolor=$col><td align=center>$date</td><td align=center><a href='$urlarr1-$cntid.html'>$arr[0]</a></td><td align=center>$view</td></tr>";
	  }
     }
     $sno = $sno+1;
   }
	
   echo"</table>";
 }
  ?>
  </td></tr>
  </table>
<?php
include '../footer.php';
?>
Return current item: Create Your Own Directory