Mysql updating multiple rows

Rated 4.16/5 based on 561 customer reviews

So, we showed only one tile containing single user details.But now, we should show multiple tiles, since we are updating multiple users at a time.UPDATE table_Foo Bar SET answer One='yes', answer Two='no', answer Three='yes' WHERE member_id = 1 AND question_id = 1; UPDATE table_Foo Bar SET answer One='no', answer Two='no', answer Three='yes' WHERE member_id = 1 AND question_id = 2; UPDATE table_Foo Bar SET answer One='yes', answer Two='yes', answer Three='no' WHERE member_id = 1 AND question_id = 3; oh, absolutely!!your problem likely lies in the php code, something about constructing variables and looping (i'm guessing -- i don't do php so i only gave your code a cursory glance) however, since you asked this question in the mysql forum, let me give you a mysql answer redesign your table, normalize it to first normal form you have repeating columns in answer One, answer Two, answer Three these should be three rows in a normalized table from there, the php will be slightly different Hello r937! To address your normalization suggestion, here is my table structure (it goes into a tiny bit more detail; my first example was a very generalized one, this one is also generalized to a certain extent) - and there is a specific reason why I have designed it so...which I will explain in a bit.And then, we can simplify it for delete operation by removing unwanted steps like a form submits and etc.We are going to take similar example seen in PHP CRUD article.After successful update, the page will be redirected to list view by using PHP location header. Because we need not show any user interface and it requires only the array of selected row ids.For multi-row delete also we are submitting selected rows by using Javascript.

And, it will look like, These values will be passed as an array of user ids to the PHP page.As shown in the following script, we can use Javascript confirm() function, to get confirmation before delete.Hi I'm hoping one of you kind folk can help with this.All the steps listed below are suitable for updating multiple rows.But, step 2, 3 is not required for deleting multiple rows.

Leave a Reply