<?php  
session_start();
if(!isset($_SESSION['atcrmsuloginsesion']))
	{
		header('Location: index.php');
		return;
	}
	if($_SESSION['atcrmsutype']!='Superuser'){
			header('Location: index.php');
		return;
	}
	
	include("connect.php");	
	include("removespecial.php");	
	header("Access-Control-Allow-Origin: *");
	
	$eve = "select * from res_faq_master order by fmid desc";
	$re = mysqli_query($conn, $eve);
	
	
	$response = array();
	$posts = array();
	
	$result="0";
	
	if(mysqli_num_rows($re) > 0)
	{
		$i=1;
		while($rt = mysqli_fetch_assoc($re))
		{
			 	$fmid=$rt['fmid'];
				$catedit="<a href='faqedit.php?id=".$rt['fmid']."' data-toggle='tooltip' data-placement='top' title='Edit' class='fa fa-pencil fa-md'>  </a>";
				
				$catdelete="<a href='faqdelete.php?id=".$rt['fmid']."' data-toggle='tooltip' data-placement='top' title='Delete' class='fa fa-trash-o fa-md' onclick='return confirm(&#39;Are you sure you want to delete ?&#39;);'> </a>";
				 $op=$catedit."&nbsp;&nbsp;&nbsp; ".$catdelete;
				
				
				$fmque=removespecialchar($rt['fmque']);
				$fmque=htmlspecialchars($fmque);
				$fmans=removespecialchar($rt['fmans']);
				$fmans=htmlspecialchars($fmans);
				
				$posts[] = array('srno'=> $i, 'fmque'=> $fmque, 'fmans'=> $fmans, 'op'=> $op);
				
				$i++;
	
		}
		 
		$response['posts'] = $posts;
		echo stripslashes(json_encode( array('data' => $posts)));
		mysqli_close($conn);
		return;
	}
	
   else
	{
		$result="0";
		$msg="Invalid Error";
		
		$posts[] = array('p1'=> $result,'p2'=> $msg);
	
		$response['posts'] = $posts;
		echo stripslashes(json_encode( array('item' => $posts)));
	}
   
	mysqli_close($conn);	
?>