<?php
	session_start();
	include_once('db/connection.php');

	if(isset($_GET['id'])){
		
		$sql = "UPDATE comments SET approve = '1', decline = '2' WHERE id = '".$_GET['id']."'";

		//use for MySQLi OOP
		if($conn->query($sql)){
			$_SESSION['success'] = 'Comment approved successfully';
		}
		///////////////

		//use for MySQLi Procedural
		// if(mysqli_query($conn, $sql)){
		// 	$_SESSION['success'] = 'Member updated successfully';
		// }
		///////////////
		
		else{
			$_SESSION['error'] = 'Something went wrong in approving the comment';
		}
	}
	else{
		$_SESSION['error'] = 'Select a comment to approve first';
	}

	header('location: index.php');

?>