in reply to MySQL "Counter"?

do I have to call it in one field, store the variable until the next line, and then increment it, then write it back?

Can you use an AUTO_INCREMENT field to assign IDs? If so, all you need to do to retrieve the value of the ID that you just assigned (by inserting into a table) is

SELECT LAST_INSERT_ID();
Check the MySQL docs for details.