Im writing a php script that will function as a waiting list. I have created a database in mysql that stores a student id number and place in line. The place in line is the primary key and starts at 1. So it looks something like.
1 9883
2 9833
3 9831
4 9332
5 9334
Administrators will be able to remove people from the list by going to a page and placing a check on each person they want to take off and then finally hitting a submit button.
The solution i have come up with is that if an id is not checked. the script will put it into an array. For example lets say 2 and 4 are checked, that means i will put 3 items in the array and I will leave out record numbers 2 and 4. so
$array[1] = 9883
$array[2]= 9831
$array[3]= 9334
I then plan on having a loop that will go through each element of the array and update
sid = student id
pid = place in line id
"UPDATE sid WHERE pid = [$count] SET sid=$array[$count]"
and then
erase the remaining elements that need to be removed.
This solution seems inefficient to me so im wondering how would other people do it. I have a problem of not being able to see a better solution when I am on to something that might work.
Any help is greatly appreciated, thank you.