sonicthehedgehog Posted September 3, 2015 Share Posted September 3, 2015 (edited) I'm not sure if I'm doing this the right way but I'm trying to update a field in the database if a checkbox is ticked but it's not working and I'd be grateful for a pair of extra eyes on the code please. This is how I'm updating the table: $query="update feed set name=".dbstr( $_POST['name'] ).", label=".dbstr( $_POST['label'] ).", delivery=".dbstr( $_POST['delivery'] ).", new_release =0, rerelease =0, live =0 where id=".dbstr( $_POST['id'] ); and this is how I'm updating it if the checkboxes are ticked: if ( isset( $_POST['new_release'] ) ) {$query="update feed new_release=1 where id=".dbstr( $_POST['id'] );}if ( isset( $_POST['rerelease'] ) ) {$query="update feed rerelease=1 where id=".dbstr( $_POST['id'] );}if ( isset( $_POST['live'] ) ) {$query="update feed live=1 where id=".dbstr( $_POST['id'] );} What's happening is that it's setting the new_release, rerelease and live fields to 0 every time. I want to be able to change this so need to have it either set to 0 or 1 Edited September 3, 2015 by sonicthehedgehog Link to comment Share on other sites More sharing options...
sonicthehedgehog Posted September 3, 2015 Author Share Posted September 3, 2015 I've just realised that I left the 'set' out of the query. Put it back and it works Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now