I have programme and I am making some tools to sort out errors. I have a table which sometimes (due to my programming) numbers have been changed by accident. I now need to change them but do not want to do it manually.
Basically the rows look something like this
Name, Age, Ref.
Matt, 23, 1
Luke, 25, 2
James, 30, 3
Mark, 20, 3 (this should be 4 but has been changed to 3 and so isnt a unique ref number)
The ref numbers should all be unique and numbered from 1 up but it has all messed up and I want to change all the ref numbers to 1,2,3... etc. It doesnt matter who has which number but I need to change lots of them so that the ref column counts from 1 up. Does anyone have any ideas. I though of using a foreach loop with a mysql query in but unsure. Appreciate any help. Thanks.