Gossamer Forum
Home : General : Perl Programming :

Pass value from different table?

Quote Reply
Pass value from different table?
I am using 2 tables "buyer" and "seller" both have same user table.

When I am logged on as buyer and viewing seller table, there is a link, if I click, it will send seller e-mail, with my personal info like FirstName and LastName.

I am using DBManSQL for main part of this.

I modified home.pm and I am able to get my email (buyer e-mail), I also got topic correct, but I am stumped with how to get seller e-mail to show and also how to get FirstName, LastName to show in message.

Quote:
my $table = $self->table(buyer);
my $sth = $table->select({ID => '1'},['LastName','FirstName']);
while (my $rs = $sth->fetchrow_hashref) {
print $rs->{field1};
my $msg = $sth;
my $to = ???????;
}

Any Advice....
And how do I get ID to show depending which record I am looking up?
Quote Reply
Re: [Hank] Pass value from different table? In reply to
I've never used DBMan, so I'm not sure if this will help.
You can do another query to get the seller email (as long as you know the seller's ID), by doing something like:
my $seller_email = $self->table(seller)->select({ID => 'sellers id'}, ['Email'])->fetchrow_array();


Adrian
Quote Reply
Re: [brewt] Pass value from different table? In reply to
Thx, but it did not work...
How about when I have ....&frm=7
7 would be the ID for the dataowner, and transfer that to email, when clicked... how? (ie keep e-mail invisible whole time)
Quote Reply
Re: [Hank] Pass value from different table? In reply to
This test sub works.... beleive it or not.
Now how do I modify thes 2 lines (#### lines)
I want to show value from sample database and color column for user ID, which comes from url (ie UserID=10, which would pick up right owner of the data, and then we would be able to select the color for example)?

Quote:
$COMPILE{just_test} = <<'END_OF_SUB';
sub just_test {
#-----------------------------------------------------------------------------
#test sub
my $self = shift;
my $test = $self->{cgi}->{from}|| $self->{user}->{'Username'};
######my $test2 = ;###### Modify this line
'Content-type' => 'text/html',
print $self->{in}->header;
print $test; # This here prints Current Username or value passed from url
######print $test2;###### Modify this line
return ('home.html',{
header => $self->_language('HEA_HOME'),
msg => ''
});

}
END_OF_SUB

Last edited by:

Hank: Nov 15, 2001, 8:56 PM