<?php
session_start();
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: X-Requested-With");

include 'config.php';



$news_id=$_POST['news_id'];


$news_id=stripslashes($news_id);
$news_id=mysqli_escape_string($con, $news_id);

$user_id=stripslashes($user_id);
$user_id=mysqli_escape_string($con, $user_id);


$data = array();


$sql=$con->query("SELECT * FROM news WHERE news_id='$news_id'") or die("Error2 : ". mysqli_error($con));


 while($rows=mysqli_fetch_assoc($sql))

   {

 $data[] = [ 
        'id' => $rows['id'],
        'news_id' => $rows['news_id'],
        'topic' => $rows['topic'],
        'content' => $rows['content'],
        'content' => $rows['content'],
        'image' => $rows['image'],
        'sender_id' => $rows['posted_by'],
        'date_posted' => $rows['date_posted'],
       
       
    ];  
    
    
    $suc="Success";
 
  }
   if($data == null)
   {
      $suc="No News";
       $data = ''; 
   }


$con->close();

$output = array('success'=>$suc, 'data'=> $data);
echo json_encode($output); //output JSON data


?>
