Gossamer Forum
Home : Products : DBMan : Customization :

Adding Record to Database using Query String

Quote Reply
Adding Record to Database using Query String
I am attempting to allow users to add records returned from one database to another using links. I have the query string set as below:
<a href="$db_script_url?db=interface&add_record=1&uid=$db_uid&ID=???&Code=$rec{'Code'}">

The "ID=???" is the part I am unable to work out. The "ID" field must be autoincrementing and I have set the Config file correctly to this end. With what code (DBMan variable) can I replace the "???" in order to place the next value from default.count into the ID field of the database I am adding the record to?

Thanx in advance
Quote Reply
Re: Adding Record to Database using Query String In reply to
You could look at the .count file for the second database.

Code:
open (ID, "<name of .count file for second db")
or &cgierr("error in get_defaults. unable to open id file: $db_id_file_name.\nReason: $!");
if ($db_use_flock) { flock(ID, 1); }
$id = <ID> + 1; # Get next ID number
close ID;

Then use

...&add_record=1&uid=$db_uid&ID=$id&Code=...

in your URL.

As long as all your files are in the same directory, there shouldn't be any problem.

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





Quote Reply
Re: Adding Record to Database using Query String In reply to
Thanks again JPD.