Gossamer Forum
Home : Products : DBMan : Customization :

DESPERATE about multiple selects from different db

Quote Reply
DESPERATE about multiple selects from different db
Greetings to all.

I'm desperate. I'm trying to use the multiple limited select fields from other db with no success. I'm able to create a a single select from an outside db ok, but not multiple.

I event tried cheating a bit and concatenating 2 single selects from an outside database but all I get is the field number instead of the value.

something like this(code):

@all_fieldnum=$other_fieldnum2 . " " . $other_fieldnum3;

Can anyone PLEASE help shed some light into this matter? I'm on a huge deadline and my poor brain is about as fried as it gets :)

Here's the code I have from Multiple select from outside database:

code:

sub build_limited_multiple_select_field_from_other_db {
# --------------------------------------------------------
# Builds a SELECT field from an external database.
# Parameters are the column to which the value will be written -- $column
# a default value -- $value
# the height of the select field -- $size (optional)

my ($column, $value, $size) = @_;
my (@fields, $field, @selectfields, $selected, $fieldnum1, $fieldnum2, @lines, $line, $output, $found, @values);
$size or ($size = 3);
@values = split (/\Q$db_delim\E/,$value);

# Be sure to change the following to match your database. The name of the other .db file
$db_other_file_name = $db_script_path . "/artists.db";

# The number of the field in the other .db file that holds the values you want in your select field
$fieldnum1 = 1;

# The number of the field in the other .db file that holds the userid.
$fieldnum2 = 0;

# End of things to edit.

for ($i = 0; $i <= $#db_cols; $i++) {
if ($column eq $db_cols[$i]) {
$found = 1;
last;
}
}
if (!$found) {
return "error building select field: no fields specified!";
}
open (DB, "<$db_other_file_name") or &cgierr("Error in build_select_field_from_other_db. Unable to open $db_other_file_name. Reason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
next if /^#/;
next if /^\s*$/;
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
if ($fields[$fieldnum2] eq $db_userid) {
if (!(grep $_ eq $fields[$fieldnum1], @selectfields)) {
push (@selectfields, $fields[$fieldnum1]);
}
}
}
close DB;

$output = qq|<SELECT NAME="Name" MULTIPLE SIZE=$size><OPTION>---|;
foreach $field (sort @selectfields) {
$selected = 0;
foreach $value (@values) {
if ($value eq $field) {
$output .= "<OPTION SELECTED>$field";
$selected = 1;
}
}
unless ($selected) {
$output .= "<OPTION>$field";
}
}
$output .= "</SELECT>";
return $output;
}


ONce again, thanks in advance:)