Ønsker ikke at opdatere de tomme felter i formen
Hej allesammen,jeg er ved at lave et galleri hvor man skal kunne opdatere et maleri. Men når man skal redigere/opdatere et maleri, ønsker jeg ikke at opdatere de tomme felter til databasen... Hvordan gør man det. Herunder er min kode indtil videre:
if(isset($_POST['updatePainting']))
{
$id = $_POST['id'];
$img = $_POST['editImgPaint'];
$minature = $_POST['editMinaturePaint'];
$mini1 = $_POST['editMini1Paint'];
$mini2 = $_POST['editMini2Paint'];
$mini3 = $_POST['editMini3Paint'];
$mini4 = $_POST['editMini4Paint'];
$kunstner = $_POST['editKunstnerPaint'];
$overskrift= $_POST['editOverskriftPaint'];
$str = $_POST['editStrPaint'];
$pris = $_POST['editPrisPaint'];
$info = $_POST['editInfoPaint'];
$video = $_POST['editVideoPaint'];
move_uploaded_file($_FILES['editImgPaint']['tmp_name'], "images/galleri/XLimg/" . $_FILES['editImgPaint']['name']);
move_uploaded_file($_FILES['editMinaturePaint']['tmp_name'], "images/galleri/paintings/" . $_FILES['editMinaturePaint']['name']);
move_uploaded_file($_FILES['editMini1Paint']['tmp_name'], "images/galleri/paintings/" . $_FILES['editMini1Paint']['name']);
move_uploaded_file($_FILES['editMini2Paint']['tmp_name'], "images/galleri/paintings/" . $_FILES['editMini2Paint']['name']);
move_uploaded_file($_FILES['editMini3Paint']['tmp_name'], "images/galleri/paintings/" . $_FILES['editMini3Paint']['name']);
move_uploaded_file($_FILES['editMini4Paint']['tmp_name'], "images/galleri/paintings/" . $_FILES['editMini4Paint']['name']);
$img_sql = (!empty($_POST['editImgPaint'])) ? ", img='" . $_POST['editImgPaint'] . "'" : "";
$mini_sql = (!empty($_POST['editMinaturePaint'])) ? ", img='" . $_POST['editMinaturePaint'] . "'" : "";
$img1_sql = (!empty($_POST['editMini1Paint'])) ? ", img='" . $_POST['editMini1Paint'] . "'" : "";
$img2_sql = (!empty($_POST['editMini2Paint'])) ? ", img='" . $_POST['editMini2Paint'] . "'" : "";
$img3_sql = (!empty($_POST['editMini3Paint'])) ? ", img='" . $_POST['editMini3Paint'] . "'" : "";
$img4_sql = (!empty($_POST['editMini4Paint'])) ? ", img='" . $_POST['editMini4Paint'] . "'" : "";
$query = "UPDATE galleri SET
" . $img_sql . "
" . $mini_sql . "
" . $img1_sql . "
" . $img2_sql . "
" . $img3_sql . "
" . $img4_sql . "
kunstner ='$kunstner',
overskrift ='$overskrift',
str ='$str',
pris ='$pris',
info ='$info',
video ='$video'
WHERE galleriID='$id'";
mysql_query($query) or die(mysql_error());
echo 'Painting er nu opdateret!';
}
Håber i kan hjælpe!