php - UPDATE SQL, only UPDATE image if not null -


i trying allow users update table has image file-upload input. filename stored in database, such image.jpg. problem if user chooses not change image clears in database since sends null value. how update image field if input file not null?

        // prepare , bind     $stmt = $conn->prepare("update news set                                          title=?,                                          content=?,                                          image=?                                         id=?");     $stmt->bind_param("sssd", $title, $content, $image, $id); 

it couldn't simpler using conditional statement:

the logic:

if(condition){ } else{ else }

which use in conjunction $_files array , example:

if(!empty($_files['file'])){    // execute sql  }  else{   // else } 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -