At 3:46 PM -0800 11/5/01, Erica Douglass wrote:
>I have a form where people can update multiple elements at the same
>time. But I run into problems when A needs to be turned into B and B
>needs to be turned into A. For instance, take a look at the queries
>generated from a particular form request:
>update sections set place="108" where place="101"
>update sections set place="101" where place="108"
>As you can see, these two queries cancel each other out.
You should make sure the table has a primary key, and make the value
of the primary key a hidden field for each record that you display
in the form. (I.e., it shouldn't be modifiable by the user of the
form.) Then you can update records unambiguously by specifying
the primary key for each record:
update sections set place="108" where key_col=key_col_val_1
update sections set place="101" where key_col=key_col_val_2
The trick is that the primary key not be editable by the user.
Otherwise you'll always have the problem that you describe above.
>Since I'd prefer to only have one form where people can update this
>specific information, does anyone have a good way to work around this?
>Can I update both of the records at the same time?
>I'd prefer to give the logic to MySQL instead of putting that logic in a