<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
//var_dump($_POST);
include('config.php');
include('functions.php');
//return updateData($connect, $post);
$arrayKeys = array_keys($_POST);
$tableNamePost = $_POST['table_name_order'];
$primeryKeyName = $_POST['table_name_order_id'];
$primaryValue = $_POST[$primeryKeyName];
foreach ($arrayKeys as $key){
if($key == 'table_name_order' || $key == 'table_name_order_id' || $key == $primeryKeyName || $key == 'action'){
}else{
$query = "
UPDATE $tableNamePost
set $key = :$key
WHERE $primeryKeyName = :$primeryKeyName
";
$statement = $connect->prepare($query);
$statement->execute(
array(
':'.$key => $_POST[$key],
':'.$primeryKeyName => $primaryValue,
)
);
$result = $statement->fetchAll();
if(isset($result))
{
$output = '<b>'.$tableNamePost.'</b> table <i> record with ' .$primaryValue . ' - ' . $primeryKeyName . '<i> is updated ';
}else{
$output = '<b>'.$tableNamePost.'</b> table <i>' . $primaryValue . '<i> record Not Updated !! ';
}
}
}
echo $output;
|