Ok, I'm thoroughly confused with what you've asked.
Once you have your INSERT query, say:
$query = "INSERT INTO MyTable ( name, data ) VALUES ( 'test1', 'my test')";
and you want the next auto increment number (assuming you have a field set as type AUTO_INCREMENT in MySQL), you simply would say:
$next_number = mysql_insert_id($mysql_connection) + 1;
[man]mysql_insert_id/man just returns the ID of the last INSERT statement.
Is this not what you wanted? If not, try to clarify your problem, posting examples of both code/desired effect if you can.