jwwceo Posted August 28, 2006 Share Posted August 28, 2006 So I finally got my checkboxes working to where I can add them to a databse, and have the correct checkboxes already "checked" on the edit page when a user comes in the make changes...however, what kind of query do I use to update any changes in the checkboxes...there might be as many as 50 boxes...say theres 20 boxes currently checked and the user checks 10 more....an UPDATE query only updates current rows...in this case I'd need to update 20 and add 10....plus all the rows will have the same shirt_id since all the checkboxes relate to the same product....does this make sense... Quote Link to comment Share on other sites More sharing options...
shocker-z Posted August 28, 2006 Share Posted August 28, 2006 Hi again..What you could do is delete all rows already in DB then loop the array to insert all checked in[code]mysql_query("DELETE * FROM tablename WHERE shirt_id = '$shirt_id'") or die (mysql_query());[/code]that will dleete them allthen use[code]foreach ($_POST['checkbox'] as $checkbox) {mysql_query("INSERT INTO table_name (shirt_id, color) VALUES('$shirt_id','$color')") or die (mysql_query());}[/code]I based the code on you still talking about the shirts and colors siteLiam Quote Link to comment Share on other sites More sharing options...
jwwceo Posted August 28, 2006 Author Share Posted August 28, 2006 Thank you Liam! You have been very helpful on this part of my project...arrays are still a little confusing and I don't know that many commands to work with them...you've shown me some cool things!!!thanks!James Quote Link to comment 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.