I have an UPDATE query and using Ajax, I wanted to know if any value is empty, I can only update the values that are not empty in the database. I don't know if it is possible to have an if statement or something to check, to skip empty values. I know that I can just add another form element, but I just wanted to find out if there is another solution.
Only if the data is POST from the front end form. If the non-POST data does not update this Title= '. $ Title. ',
$id = $_POST['id'];
$title = "";
$description = $_POST['Description'];
$date = $_POST['Date'];
$query = 'UPDATE user SET
`id` = '.$id.',
`Title` = '.$title .',
`Description` = '.$description.',
`Date` = '.$date =.'
WHERE `id` = '.$id;
$result = mysql_query($query) or die("<b>A fatal MySQL error occured</b>.<br />Query: ".$query."<br />Error: (".mysql_errno().") ".mysql_error());
Update: This is what worked for me. Thanks Karim Daraf
$ query = "UPDATE user SET Title= Coalesce ($ title, Title) etc.