<?php

include_once("_dirinfo.php");
include_once(PATH_TO_ROOT."init.php");
ini_set("display_errors", 1);

if($_POST['action'] == "deleteQuestion"){
    $id = mysql_real_escape_string($_POST['id']);
    $projectId = mysql_real_escape_string($_POST['projectId']);

    $sql = "SELECT proj_name FROM ".DB_WARPIT_WEBCATI_BASE."._Projects WHERE id = ".$projectId;
    if(!$res = $db->SQLexecute($sql)) die($db->JsonError());
    $row = $db->fetchRow($res);
    $projectName = $row[0];


    $sql = "UPDATE ".DB_WARPIT_WEBCATI_BASE.".`{$projectName}_structure` SET flag_bad = 54 WHERE id = ".$id;
    if(!$db->SQLexecute($sql)) die($db->JsonError());

    $r['success'] = true;

    $r['projectId'] = $projectId;
    $r['projectName'] = $projectName;

    echo json_encode($r);
}

?>
