Thanks Jim
The 2nd option is more feasible for me because inserting a empty record then 
update it and then delete the empty records if user not submit the form 
required extra work. Any how thanks for the help for every expert (Michael,Paul 
Herring,Shahu)who reply me.  
Imran Shafiq Khan

--- On Wed, 14/4/10, Jim Mullen <j...@idimensionz.com> wrote:

From: Jim Mullen <j...@idimensionz.com>
Subject: Re: [php_mysql] Solution required for MySQL ??
To: php_mysql@yahoogroups.com
Date: Wednesday, 14 April, 2010, 19:04







 



  


    
      
      
        There are times when that won't work.  For example, if customer A 

starts filling out the form and you display 101.  However, they get 

interrupted and don't complete the form.  Customer B starts filling out 

the form.  How will the system know what ID to give customer B?  It 

can't know because it doesn't know who will actually submit their form 

first and actually be assigned that ID by the DB.



While it is possible to pass a value into an auto-increment field in the 

(database) DB, it defeats the purpose of having the field be an 

auto-increment field.  If you're going to pass in a value for that 

field, don't bother making it auto-increment.



If there is a valid business requirement for displaying the customer ID 

while the customer is filling out the form, then the solution is to 

insert a blank record into the DB, get the value of the auto-increment 

field using PHP's mysql_insert_ id() function, display that on the form, 

and then update that record when customer submits the form.  The problem 

with that solution is that if the customer does not submit the form, you 

end up with a bunch of empty records in the database.



I would question why there is a business requirement to display the 

customer ID *while the customer is filling out the form*.  I would 

suggest, instead, that the ID could be displayed to the customer 

immediately after the form has been submitted (in addition to a message 

indicating that the data was saved successfully) .  That will allow you 

to get the value from the auto-increment field AND prevent empty records 

from existing in the database.



Best regards,

Jim M.

iDimensionz <http://www.idimensi onz.com> - professional web site 

programming / design and affordable web site hosting.



On 4/14/10 5:11 AM, Shahu wrote:

> hi,

> do one thing

> pass 101 value in ur insert query instead of blank..

>

> On Wed, Apr 14, 2010 at 1:32 PM, imran shafiq<jibreel_amin@ yahoo.com>wrote:

>

>>

>> Dear Exerts

>>

>> I need to display the Customer_ID on the form when user enter the info.e.g.

>> if 100 records are saved when user goto form to enter customer info the

>> record no 101 is shown

>> But you know that when user submit the form then auto increment field is

>> incremented 1

>> Customer

>> Customer_ID Auto_increment

>> First Name

>> Last Name

>> Address

>> Phone

>>

>> What is the solution?

>>

>> Imran Shafiq Khan

>>

>> [Non-text portions of this message have been removed]

>>

>>

>>

>

>



[Non-text portions of this message have been removed]





    
     

    
    


 



  






      

[Non-text portions of this message have been removed]

Reply via email to