Having a problem with updating a picture.I need to replace the current picture in the DB by allowing the users to browse a picture and uploading it.And if the user did not upload any image I need to keep the current picture as it is.
I wrote something like this,but its not working ..
if (isset($_POST['btnModifyCategory'])){
$cid = $_POST['catId'];
$name2 = $_POST['txtName'];
$description2 = $_POST['catDesc'];
if(isset($_FILES['file']))
{
$image2 = uploadImage();
}
//update the database with new values.
if(isset($_FILES['file']))
{
if($_FILES['file']['name'] != "")
{
$sql2 = "UPDATE tbl_category SET cat_name ='$name2', cat_description='$description',cat_image='$image' WHERE cat_id = '$cid'";
$result2 = mysql_query($sql2) or die(mysql_error());
}
else
{
$sql2 = "UPDATE tbl_category SET cat_name ='$name2',cat_description='$description' WHERE cat_id = '$cid'";
$result2 = mysql_query($sql2) or die(mysql_error());
}
}
}
(Im not posting the uploadImage() here ,since it is working properly.)
How can I do it..Can someone do it for me.Thank you..!