Gossamer Forum
Home : Products : DBMan : Customization :

A way of printing field value when posted to atext

Quote Reply
A way of printing field value when posted to atext
Is there a way to have the db.cgi file print a specified field value to a text file and overwrite and update whenever someone enters data to the DB?

thanks in advance!

Quote Reply
Re: A way of printing field value when posted to atext In reply to
Probably, but I would need more detail about what you want to do.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: A way of printing field value when posted to atext In reply to
okay
say we have database named sample
in sample there is 4 fields, field1,field2,field3,field4

now, somewhere else, there is a field.txt file
and whenever someone adds a record to the db lets say field2 is printed to field.txt ( over whatever exists there)

get it?


Quote Reply
Re: A way of printing field value when posted to atext In reply to
Okay.

In your .cfg file define a variable

$field_text = $db_script_path . "/field.txt";

Be sure that you upload a file by that name to your DBMan directory and set the permission to 666.

In db.cgi, sub add_record, after

close DB; # automatically removes file lock

add

Code:

open (TEXT, ">$field_text") or &cgierr("error in add_record. unable to open text file: $field_text.\nReason: $!");
if ($db_use_flock) {
flock(TEXT, 2) or &cgierr("unable to get exclusive lock on $field_text.\nReason: $!");
}
print TEXT $in{'field2'};
close TEXT;

JPD
http://www.jpdeni.com/dbman/