Hi guys,
I have come accross a small problem while trying to convert a java program to a PHP 
one....
my database table is like so

*************
cno (int)
name (varchar)
lastname(varchar)
etc etc
*************

as you can see the details I take is name/lastname and customer number (cno) is 
automatically generated, now instead of using a "auto increment" a "int" was declared 
and this code was used

**************************
synchronized(this) 
{ 
rs=stmt.executeQuery("select max(cno)+1 from cust");
}
**************************

(for those of you who dont understand java)
the "synchronized" keyword makes sure only one thread can work in the "block" of code 
between the "{" and "}" then it executes the query "select max(cno)+1 from cust" and 
stores the result in an array (like PHP) in "rs".

Basically, it just gets the next higher cno from the table cust.

Then it enters the cno like this rs=cno,then name,lastname etc and then tells the 
customer that the data has been entered and his new customer number is <rs>.


As you can see its a pain in the ass job which has to be changed,
the problem is a few hundred records have already been entered,
how do i use the current table BUT use the more useful auto increment and 
LAST_INSERT_ID() via PHP?
The java servlet program which is handleing the requests is working fine, but I am 
want to convert it to a PHP program as paying for servlet hosting is upto 5-8 times 
more...and I aint rich, or even close to being rich :-(


Please reply,
ANY help appreciated and thanks in advance.
Cheers,
-Ryan.

Reply via email to