Well the UPDATE statement is scoped to UPDATE all rows, each time through the loop. You need a WHERE clause on it. But I still don't understand what the $pointer loop has to do with the update loop. Which rows are you trying to update? What belongs in the WHERE clause?