I have a $_POST array which consists of multiple values of a form. Below is the sample array. This array can consist values for multiple users. But the format would remain the same.
Array ( [user1_mon_shift] => S1(Morning) [user1_tue_shift] => S1(Morning) [user1_wed_shift] => S3(Night) [user1_thu_shift] => Earned Leave [user1_fri_shift] => S2(Afternoon) [user1_sat_shift] => [user1_sun_shift] => [user2_mon_shift] => S1(Morning) [user2_tue_shift] => S2(Afternoon) [user2_wed_shift] => S3(Night) [user2_thu_shift] => S3(Night) [user2_fri_shift] => S3(Night) [user2_sat_shift] => On Call [user2_sun_shift] => On Call [submit] => consolidatedss )
I want to write a php code which would achieve the below.
1. Create an sql query for the first user user1
example UPDATE user1 SET user1_mon_shift='S1(Morning)', user1_tue_shift = 'S1(Morning)', user1_wed_shift = 'S3(Night)', user1_thu_shift = 'Earned Leave', user1_fri_shift = 'S2(Afternoon)', user2_sat_shift = 'On Call', user2_sun_shift = 'On Call' WHERE condition
. Here condition i can define.
2. Afterwards execute the query, then create a sql query for next user for example user2
in similar way and execute and so on for other users.
Kindly let me know if anything else is required.
Thanks in advance.