[ic] Counter - auto_increment primary key - need help????

Stefan Hornburg Racke interchange-users@interchange.redhat.com
Thu Apr 4 07:07:01 2002


Alma Nuker <alma@youramigo.com> writes:

> Hi guys;
> 
> I am using counter for few my pages and it works fine, no problems.
> 
> But what I really want to do now is following:
> 
> 1. I want to have serial_number that is unique primary key.
> 
> 2. I need to icrement it by one everytime when record is store in db.
> 
> I tried using counter but it is not really helpping me much, since
> counter increases everytime when I accress page regardles if I have
> stored ianything in db or not.
> I need this serial_number to increase by one only if I did store
> something in db.
> 
> 
> I know that you will say, why not use auto_increment number. I tried
> that one but issed with that one is following:
> 
> I input values in db using form. serial_number is defined, all values
> are saved to db no problems there.
> 
> Now I nedd to add some additional information for that particular
> serial_number. I am using perl script to do so, but than I am not sure
> how to make reference to serial_number any more.
> 
> For example I tried folllowing:
> 
> Lets say that I have following in my db:
> serial_number UNISGNED AUTO_INCREMENTPRIMARY KEY
> company
> email_address
> some_value    etc ...
> 
> So say that I have form to input company and email address as follow:
> 
> <FORM ACTION="[process]" METHOD="POST">
> <INPUT TYPE=HIDDEN NAME="mv_data_table"    VALUE="mydb">
> <INPUT TYPE=HIDDEN NAME="mv_data_key"      VALUE="serial_number">
> <INPUT TYPE=HIDDEN NAME="mv_data_function" VALUE="insert">
> <INPUT TYPE=HIDDEN NAME="mv_nextpage" VALUE=@@MV_PAGE@@>
> <INPUT TYPE=hidden NAME="mv_form_profile" VALUE="mydb_profile">
> <INPUT TYPE="HIDDEN" NAME="mv_data_fields"
> VALUE="serial_number,company,email_address, some_value">

Add here

<INPUT TYPE="HIDDEN" NAME="mv_data_return_key" VALUE="serial_number">

That will set $CGI->{serial_number} to the new key.

Ciao
        Racke

-- 
Think of it !

For projects and other business stuff please refer to COBOLT NetServices
(URL: http://www.cobolt.net; Email: info@cobolt.net; Phone: 0041-1-3884400)