[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] Counter - auto_increment primary key - need help????
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">
<INPUT TYPE="hidden" NAME="serial_number" VALUE="">
<table>
<TR>
<TD COLSPAN="3" BGCOLOR="#FFDD99"><FONT SIZE="2"
COLOR="#134582"><STRONG>Details:</STRONG> </FONT></TD></TR>
<INPUT TYPE="hidden" NAME="username" VALUE="[data session username]">
<tr class="contentbar1">
<TD VALIGN="TOP" ALIGN="LEFT" BGCOLOR="#FFDD99">
<FONT SIZE="2" COLOR="#134582">[error name=company
std_label="Organization (*)" required=1]</FONT></TD>
<TD COLSPAN="2" BGCOLOR="#D7D7D7">
<INPUT TYPE=text NAME=company VALUE="[value company]" size="52"
maxlength="50">
</td>
</tr>
<TR> <TD VALIGN="TOP" ALIGN="LEFT" BGCOLOR="#FFDD99">
<FONT SIZE="2" COLOR="#134582">[error name=email_address
std_label="Email Address (*)" required=1]</FONT></TD>
<TD COLSPAN="2" BGCOLOR="#D7D7D7"><INPUT TYPE="TEXT" NAME="email"
SIZE="52" MAXLENGTH="50" VALUE="[value email_address]"></TD></TR> <INPUT
TYPE=hidden NAME="mv_todo" VALUE="set">
<INPUT TYPE="SUBMIT" NAME=mv_click VALUE="Register Now">
<INPUT TYPE="Reset">
[set Register Now]
mv_nextpage=ord/send_something
[/set]
</TABLE> </FORM>
Now on next page (send_something) I have some perl script that uses my
defined tag to obtain value of some_value.
That all works fine. Now I am just trying to work out how to add this
some_value in mydb for this particular serial_number.
This is what I have on my page:
[tag flag write]evaluationdb[/tag]
[perl]
$em = $Values->{email};
$cn = $Values->{company};
$junk = $Values->{some_value} = $Tag->get_some_value($em,$cm);
<above works fine since I am getting what I want using this tag>
I am trying to insert this in db as follow:
$junk = $Tag->data(
{
table => mydb,
field => some_value,
key => $Values->{serial_number},
value => $Values->{some_value} ,
}
);
return;
[/perl]
Problem with this one is that inserts some_value in wrong spot in mydb.
I need this to be inserted in already existing record, instead it has
been added as new record in mydb.
So now in mydb instead having:
serial_number company email_address some_value
1 somecomp some@email 1222222
I have
serial_number company email_address some_value
1 somecomp some@email
2 1222222
I tried everything but I can not make it work.
If you have any ideas please share them with me.
I feel really frustrated but do not have any ideas what else I can try.
Thank you
Alma