easier way to do this:
In your .cfg file, create a new variable to hold the fieldnames that will be created from the external databases.
code:
$db_external_select_fields = 'Userid';
In db.cgi, create a subroutine: code:
sub build_external_select_field {
#------------------------------------
my ($column, $value) = @_;
my ($output,$external_db,$found,$field,@selectfields);
foreach $col (@db_cols) {
if ($column eq $col) {
$found = 1;
last;
}
}
if (!$found) {
return "error building select field: no fields specified!";
}
$output = qq|<SELECT NAME="$column">|;
$external_db=$db_script_path . '/' . lc($column) . '.db';
open (DB, "<$external_db") or &cgierr("unable to open $column.db. Reason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
next if /^#/;
next if /^\s*$/;
$line = $_;
chomp ($line);
push (@selectfields, $line);
}
close DB;
foreach $field (sort @selectfields) {
($value =~ $field) ?
($output .= "<OPTION SELECTED>$field") :
($output .= "<OPTION>$field");
}
$output .= "</SELECT>";
return $output;
}
In html_build_record_form, after the line that starts with
if ($db_select_fields{$field}) {...
add code:
elsif ($db_external_select_fields =~ $field) {
$output .= "<TR><TD><$font>$field:</font></TD><TD" . &build_external_select_field($field, $rec{$field}) . "</TD></TR>";
}
As always, should you or any of your IM force be caught or captured-- Oh, wrong context.
As always, this is untested, except for sytax errors.
i copied above from an old post and edited it a little. ;you would take Userid out of the &db_select_fields in all the config files and use the following instead.
$db_external_select_fields = 'Userid';
then you would have a database that contained all the Userid's.
i suggest you use a common .pass file that already exists instead of a new file. if you use pass file you will need to make a few changes to the code above. if you need help with that, get it started and let me know!
In your .cfg file, create a new variable to hold the fieldnames that will be created from the external databases.
code:
$db_external_select_fields = 'Userid';
In db.cgi, create a subroutine: code:
sub build_external_select_field {
#------------------------------------
my ($column, $value) = @_;
my ($output,$external_db,$found,$field,@selectfields);
foreach $col (@db_cols) {
if ($column eq $col) {
$found = 1;
last;
}
}
if (!$found) {
return "error building select field: no fields specified!";
}
$output = qq|<SELECT NAME="$column">|;
$external_db=$db_script_path . '/' . lc($column) . '.db';
open (DB, "<$external_db") or &cgierr("unable to open $column.db. Reason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
next if /^#/;
next if /^\s*$/;
$line = $_;
chomp ($line);
push (@selectfields, $line);
}
close DB;
foreach $field (sort @selectfields) {
($value =~ $field) ?
($output .= "<OPTION SELECTED>$field") :
($output .= "<OPTION>$field");
}
$output .= "</SELECT>";
return $output;
}
In html_build_record_form, after the line that starts with
if ($db_select_fields{$field}) {...
add code:
elsif ($db_external_select_fields =~ $field) {
$output .= "<TR><TD><$font>$field:</font></TD><TD" . &build_external_select_field($field, $rec{$field}) . "</TD></TR>";
}
As always, should you or any of your IM force be caught or captured-- Oh, wrong context.
As always, this is untested, except for sytax errors.
i copied above from an old post and edited it a little. ;you would take Userid out of the &db_select_fields in all the config files and use the following instead.
$db_external_select_fields = 'Userid';
then you would have a database that contained all the Userid's.
i suggest you use a common .pass file that already exists instead of a new file. if you use pass file you will need to make a few changes to the code above. if you need help with that, get it started and let me know!