Are you referring to a table's surrogate key? If so, then simply don't. It will cause more headaches than its worth to reuse keys than any benefit of reordering them especially if cascading relationships are not set up.
Of course you can just not use surrogates and apply an actual property for the primary key instead.
If you refer to something within the output, than that's no problem. Building a table with an incrementing column value is as simple as using a
print ++$i; in it. Although that likely isn't the case here since you will only see a problem if you are referring to a PK or if JS is used to remove in which case it then becomes JS' job to worry about.
ahh, beaten this time.