[Solved] adding php if condition in mysql query


Keep space between your concatenation,

$ok = 1;

$sql = "UPDATE users SET
        fn  = :first,
        ln  = :last";
    if($ok == 1){
        $sql .= ", phone = :phone ";
    }

$sql .= " WHERE users.id = :id";

0

solved adding php if condition in mysql query