<?php
session_start();
if(!isset($_SESSION['user'])) {
	header("location: ../index.php");
	exit;
}

include "../dbconnect.php";

$client_id = 62;
$outlet_id = 1;

if(isset($_POST['edit_row'])) {
	$name = $_POST['name_val'];
	$id = $_POST['row_id'];
	$ques_for = $_POST['ques_for'];
	
	$qry = mysql_query("SELECT max(fb_ques_id) AS ques_id FROM `feedback_ques`");
	$row = mysql_fetch_array($qry);
	$ques_id = $row['ques_id'];
	$inc_ques_id = $ques_id + 1;

	mysql_query("INSERT INTO `feedback_ques`(`client_id`, `outlet_id`, `fb_ques_id`, `fb_ques`, `fb_ques_for`, `fb_ques_enable`) VALUES('$client_id', '$outlet_id', '$inc_ques_id', '$name', '$ques_for', '1')");
	
	mysql_query("UPDATE `feedback_ques` SET `fb_ques_enable` = '0' WHERE `fb_ques_id` = '$id'");
}

if(isset($_POST['edit_row_del'])) {
	$name = $_POST['name_val'];
	$id = $_POST['row_id'];
	$ques_for = $_POST['ques_for'];
	
	$qry1 = mysql_query("SELECT max(fb_ques_id) AS ques_id FROM `feedback_ques`");
	$row1 = mysql_fetch_array($qry1);
	$ques_id = $row1['ques_id'];
	$inc_ques_id = $ques_id + 1;

	mysql_query("INSERT INTO `feedback_ques`(`client_id`, `outlet_id`, `fb_ques_id`, `fb_ques`, `fb_ques_for`, `fb_ques_enable`) VALUES('$client_id', '$outlet_id', '$inc_ques_id', '$name', '$ques_for', '1')");

	mysql_query("UPDATE `feedback_ques` SET `fb_ques_enable` = '0' WHERE `fb_ques_id` = '$id'");
}

?>