Gossamer Forum
Home : Products : DBMan : Customization :

Adding more than one record at a time

Quote Reply
Adding more than one record at a time
Hi, I am still working on beening able to add more than one record at a time to dbmans db. So, if some one can steer me with a little code, I think it can be done. If not I will have fun trying! Now, I need the command structure to add 1 to the record ID.
i.e. 789 + 1 and in the ID field 790 showes up. Here is where I would like this to happen: VALUE="$rec{'ID'}" and one added to the number retrieved from the count.db.
code:
<TABLE WIDTH="536" CELLPADDING=0 CELLSPACING=0 BORDER=0 BGCOLOR="#FFFFCC">
<TR> <TD align="center">
<INPUT TYPE="hidden" NAME="ID" VALUE="$rec{'ID'}" SIZE="3" MAXLENGTH="3">
<tr><$font>Qty:</FONT><font color=white>Qty:</FONT><$font>Email:</FONT> <font color=white>Qty12345</font><$font>Date:</FONT><font color=white>Qty12345</font><$font>Category:</FONT><font color=white>Qty1234567</font><$font>Price:</FONT></tr>
<td> <INPUT TYPE="TEXT" NAME="Qty" VALUE="$rec{'Qty'}" SIZE="5" MAXLENGTH="5">

<INPUT TYPE="TEXT" NAME="Email" VALUE="$rec{'Email'}" SIZE="12" MAXLENGTH="30">

<INPUT TYPE="TEXT" NAME="Date" VALUE="$rec{'Date'}" SIZE="12" MAXLENGTH="12">

|; print &build_select_field ("Category", "$rec{'Category'}"); print qq|

<INPUT TYPE="TEXT" NAME="Price" VALUE="$rec{'Price'}" SIZE="7" MAXLENGTH="8"></TD>
<TR><TD>
<$font>Description:</FONT>
<TEXTAREA NAME="Description" ROWS="2" COLS="40" WRAP="VIRTUAL" MAXLENGTH="255">$rec{'Description'}</TEXTAREA></TD></TR>
</TABLE>

------------------
Sherwin Sales@jse.net
Quote Reply
Re: Adding more than one record at a time In reply to
Hi, Is there no one to help? I know the request seems simple. But I am a beginner with perl. Sorry?



------------------
Sherwin Sales@jse.net
Quote Reply
Re: Adding more than one record at a time In reply to
I don't understand what you intend the code you posted to do.


------------------
JPD





Quote Reply
Re: Adding more than one record at a time In reply to
What I want it to do is to add one to the last number that is in the default.count file before displaying it in the ID box.

------------------
Sherwin Sales@jse.net
Quote Reply
Re: Adding more than one record at a time In reply to
The following code opens the .count file, reads the contents and increments it:

Code:
open (ID, "<$db_id_file_name") or &cgierr("unable to open id file: $db_id_file_name.\nReason: $!");
if ($db_use_flock) { flock(ID, 1); }
$rec{$db_key} = <ID> + 1; # Get next ID number
close ID;

To write the new number to the .count file, use

Code:
open (ID, ">$db_id_file_name") or &cgierr("unable to open id file: $db_id_file_name.\nReason: $!");
if ($db_use_flock) {
flock(ID, 2) or &cgierr("unable to get exclusive lock on $db_id_file_name.\nReason: $!");
}
print ID $rec{$db_key}; # update counter.
close ID;

I'm assuming that you're doing this within sub html_record, so you would want to use the $rec{$db_key}.

------------------
JPD