Tuk Posted January 30, 2010 Share Posted January 30, 2010 Hello. I ran into a hitch today and still haven't been able to find a way around it. I was hoping someone here would see a solution. This script is for a browser-based game that allows users to own animals and feed them, etc. This particular file is where the users assign a food to their animals. It is a form with a loop to display all the animals owned by the user, each with a checkbox that has the animal's id# from the database as the value. Here is the checkbox input within the loop: <input type=checkbox name="whichanimal[]" value=<? echo $animals['aid'];?> Once they've pressed Submit, this is the script that runs to assign the proper food type (variable obtained from the URL using $_GET): $update_ids = @implode(",",$_POST['whichanimal']); $query = @mysql_query("UPDATE animals SET assignedfood = '$foodid' WHERE aid IN ($update_ids)"); All of this works perfectly fine. My issue is that I want users to be able to uncheck a checkbox and when they submit the form, it 'unassigns' the food (sets it to 0). My problem is that the checkbox is within a loop... My thought was that if there is an opposite command to IN (in the update query), I could use it to get all the animals the user owns who weren't checked and set their assignedfood to 0... Does such a command exist? Is there some other way I'm totally missing? Please let me know if you need anymore info, and thank you in advance for any insight. - Tuk Quote Link to comment https://forums.phpfreaks.com/topic/190319-values-from-unchecked-checkboxes/ Share on other sites More sharing options...
trq Posted January 30, 2010 Share Posted January 30, 2010 Does such a command exist? NOT IN Quote Link to comment https://forums.phpfreaks.com/topic/190319-values-from-unchecked-checkboxes/#findComment-1004081 Share on other sites More sharing options...
Tuk Posted January 30, 2010 Author Share Posted January 30, 2010 Thank you! I'm now encountering separate problems but I believe I can solve it all from here. Thanks so much for the response. Quote Link to comment https://forums.phpfreaks.com/topic/190319-values-from-unchecked-checkboxes/#findComment-1004089 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.