$q = select max(id) as id from table
$new_id = odbc_result($q,1) +1;
even if forget about twisted sintax, this construction is meaningless.
what if you have 200 rows, and delete row number 100?
i think the best solution is that you create table called table_sys, fields : table name, current value.
with this table you can manage all tables current values.
weird solution. as weird, as i am 🙂
mysql take a care about autoincremented id's automatically.
IMO there isn't any reason to create additional table to store things, wich we can simply get with LAST_INSERT_ID()
If you keep doing that every day the database becomes fragmented
don't worry and relax. this kind of fragmentation is normal. defragmentation can make more hurt then pleasure.
f.e. if you have rows with id 1, 2, 4, 5 and you wish to make em defragmented, so you set id 4=3 and 5=4
OK, you get what you want, but if row with id 4 referenced from another table you get your database breaked out.
if you mean phisical fragmentation, you should read about ANALYZE TABLE statement.
thar's all what comes in my mind now.
Regards, Dan.