<?php

include "../classes/class.loader.php";
$db = new db();

$table_name = $_POST['table_name'];
$value = $_POST['value'];
$column = $_POST['column'];
$where = $_POST['where'];

if ($table_name == "user_breeder_info") {
    $check_res = $db->query("SELECT * FROM user_breeder_info WHERE user_id = {$_SESSION['user_id']}");
    if ($check_res->num_rows == 0) {
        $db->query("INSERT INTO `user_breeder_info`(`name`, `contact_number`, `reg_no`, `kennel_reg_no`, `papa`, `company_psira_no`, `user_id`) VALUES ('','','','','','','{$_SESSION['user_id']}')");
    }
    $update = $db->query("UPDATE `user_breeder_info` SET `$column` = '$value' WHERE $where");
    if ($update) {
        echo 1;
    } else {
        echo 0;
    }
} else {
    $update = $db->query("UPDATE `$table_name` SET `$column` = '$value' WHERE $where");
    if ($update) {
        echo 1;
    } else {
        echo 0;
    }
}

