<?php
include "../../config/master.php";

$id    = $_POST['id'];
$title = mysqli_real_escape_string($conn,$_POST['title']);
$date  = $_POST['news_date'];
$desc  = mysqli_real_escape_string($conn,$_POST['description']);

$image_query = "";

// IMAGE UPDATE
if(!empty($_FILES['image']['name'])){

$target_dir = "../../uploads/news/";

$ext = pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION);
$image = "news_".time().rand(100,999).".".$ext;

move_uploaded_file($_FILES['image']['tmp_name'],$target_dir.$image);

$image_query = ", image='$image'";
}

mysqli_query($conn,"
UPDATE village_news SET
title='$title',
news_date='$date',
description='$desc'
$image_query
WHERE id='$id'
");
?>