Rique, With almost any SQL database you can "select max(column) + 1 " (or some such) to get the next available number, but if you plan to have more than one user on the database at the same time, what will you use to prevent them both from getting the same number and attempting to save over each others information (I am assuming this is something like a record number).
Techniques to reserve the number in advance cause problems when the user changes his mind and never saves his record, leaving unused numbers in your sequence. A more common technique which is employed by most databases, is to not make any promises about numbers that will be used. The number is assigned when the user finally makes up his mind and commits to adding the record (see MySQL auto increment feature) and the system prevents multiple inserts from getting the same number. After the insert completes, the user is now told what number was used for future reference. I believe mssql also uses this technique. If you still need to reserve the number, then insert a blank record (row) and see what number was assigned and perform all further updates to that record. This technique will prevent multiple users from being assigned the same number (the query above will not). hope this helps, Warren Vail -----Original Message----- From: Rique Gresham [mailto:[EMAIL PROTECTED] Sent: Friday, November 07, 2003 10:24 AM To: [EMAIL PROTECTED] Subject: [PHP] PHP, SiteSpinner and MS SQL2000 Hi All, What I'm trying to do is query a mssql database using a SELECT statement to get the last report number from a table, increment that number by 1 and have it display in a INPUT box. The data will not INSERT into the database as a new record until one presses the SUBMIT button. PHP 4.3.2 SiteSpinner HTML MS SQL2000 Thanks, Rq -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php