Ok I'm sure this can be done I saw something similar on this post Updating multiple rows in MySQL
So what I need to make sure of is how I would wright it for mine. I have a database that lists a primary location for a staff member as well as their other associated office locations. I want to be able to update the table that holds that information for a single staff member, but I won't know exactly how many times I need to loop through.
So say I have Sally and she is associated with 2 office locations St. Paul and Chicago. Then I have Peter who is associated with only New York.
Table would be as follows
For Sally
Primary key 101
LocationID 1
StaffID 1
PrimaryLoc 1
Primary key 102
LocationID 2
StaffID 1
PrimaryLoc 0
for Peter
Primary key 103
LocationID 3
StaffID 2
PrimaryLoc 1
I know to insert one would be
UPDATE loc_tbl SET locationID=%s, PrimaryLoc=%s WHERE staffID=%s
so if I want to loop through this would I use a for loop like this? the ... is for the section where it is pulling stuff from a few text boxes.
for($i=$totalRows; $i>=0;$i--){
UPDATE loc_tbl SET locationID=%s, PrimaryLoc=%s WHERE staffID=%s ....
}
Or is there a better way to do this?