<?php
session_start();
ini_set('max_execution_time', 300000);
include("include/setsession.php");
include("include/functions.php");
require_once("include/connect.inc");
mysqli_query($link, "SET character_set_results=utf8");

$txt="0";
$id = 0;
$description="";

if (isset($_POST['id']) && $_POST['id']!='') 				$id = $_POST['id'];
if (isset($_POST['description']) && $_POST['description']!='') 	$description = $_POST['description'];

if($id==0) {
	$id=1;
	$sql="SELECT MAX(id) AS maxid FROM ".$s_prefix."_editionstype";
	$val = mysqli_query($link, $sql) or die('Query failed: ' . mysqli_error($link));
	if($res = mysqli_fetch_array($val, MYSQLI_ASSOC)) {
		$id=($res['maxid']+1);
	}
	
	$sql="INSERT INTO ".$s_prefix."_editionstype (id, description) VALUE (".$id.", '".checkStringa($description)."')";
	$res = mysqli_query($link, $sql) or die('Query failed: ' . mysqli_error($link));
} else {
	$sql="UPDATE ".$s_prefix."_editionstype SET description='".checkStringa($description)."' WHERE id=".$id;
	$res = mysqli_query($link, $sql) or die('Query failed: ' . mysqli_error($link));
}

header("Location: index.php?sz=0&go=showEditionsType");
?>