I wish to UPDATE the database column "trip_status" IF it is NOT equal to "rider_cancelled".
Here is what I have now:
$sql= mysqli_query($con, "UPDATE ride_trips SET driver_name_id = '$dname', driver_phone = '$driver_phone', pu_eta = '$eta', message_number = '0', message = '', trip_status = 'driver_on_way', trip_active = '1' WHERE id = '$id' AND pid = '$pid'");
I have tried:
$sql= mysqli_query($con, "UPDATE ride_trips SET driver_name_id = '$dname', driver_phone = '$driver_phone', pu_eta = '$eta', message_number = '0', message = '', trip_status = IF(trip_status != 'rider_cancelled' THEN SET trip_status = 'driver_on_way', trip_active = '1' WHERE id = '$id' AND pid = '$pid'");
I also don't wish the UPDATE to occur if "trip_status = 'rider_cancelled'
CodePudding user response:
If you want to update everything when "trip_status" is NOT equal to "rider_cancelled", use this:
$sql= mysqli_query($con, "UPDATE ride_trips SET driver_name_id = '$dname', driver_phone = '$driver_phone', pu_eta = '$eta', message_number = '0', message = '', trip_status = 'driver_on_way', trip_active = '1' WHERE id = '$id' AND pid = '$pid' AND trip_status != 'rider_cancelled'");