I am submitting a form where I am updating the state id
, city name
and city image
.
When I only update the image, it works.
When I update state id
and city name
and want my old image to remain the same, the photo field become blank in the database.
My PHP code is like this:
<?php
if(isset($_POST) && $_POST['submit'] == "Update")
{
extract($_POST);
if($_FILES['photo'])
{
$cityimg = upload_file($_FILES['photo'],'cityimg/','image','N','true','thumb/', 100, 100);
$sql = "UPDATE city SET mcid = '$mcid', city_name = '$city_name', photo = '$cityimg' WHERE cid = '$cid'";
}
else
{
$sql = "UPDATE city SET mcid = '$mcid', city_name = '$city_name' WHERE cid = '$cid'";
}
$result = mysql_query($sql);
if($result)
{
$msg = "City Updated Successfully.";
}
}
?>
I think that my loop is having some problem.