For $i is equal to zero and while $i is less then zero then inrement $i by one.
If it even runs it does it one time and one time only.
Not knowing where you more about your code, I would suggest you create an API controller to handle this and use ajax to hit the endpoint to change this number,
Also I small reminder never update anything in the database with a GETrequest.