[Solved] PHP: Create SQL query for available $_POST variable [closed]


you can use this :

<?php
$update = "";
foreach($_POST as $key => $value) {
   if(!empty($value)) {
     $update .= $key. "='".$value."',";
   }
}
$update = substr($update,0,-1);
$query = "UPDATE table_name SET ".$update." WHERE id=$id";

?>

solved PHP: Create SQL query for available $_POST variable [closed]