Thread Perl/cgi: Datenbank (2 answers)
Opened by Gast at 2005-04-22 12:42

Gast Gast
 2005-04-22 12:42
#4864 #4864
Hallo
Ich habe eine Datenbank mit einer Tabelle "constact_costums"  und einem Zellenname "the_value (Beschreibung der Firma). Ich habe eine Perl Anwendung, die mir erlaubte, den Namen der Firmen zu sehen. Jetzt wünsche ich, wenn ich an einen Namen klicke, es komme mit ihm the_value (Beschreibung der Firma). Ist hier der Code:
Danke

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
my $cont_id = param("id"); 
my $rc_name = param("name");
my $rc_value = param("the_value");
my (@custrc,@mos,@objs);                        # declare GLOBAL vars

print "Content-type: text/html\n\n";

### SQL queries ######

# connect to database
my $dbh = DBI->connect ($dsn, $user_name, $password, { RaiseError => 1, LongReadLen => 4096 });

if($cont_id eq ""){

my $sth = $dbh->prepare ("SELECT the_value FROM contacts_customs " );

$sth->execute ();
  my $out = $sth->fetchall_arrayref;
  @custrc = @$out;

  $sth->finish;
  $dbh->disconnect;
}

print "<html><head><title>SANTA";

print "<html><head><title>BESCHREIBUNG - SANTA<\/title><\/head>";
print "<link rel=stylesheet type=\"text/css\" href=/styles_ratecard.css><\/head>";
print "<body topmargin=15 leftmargin=12>";

## Process query output ###

# show the overview of available description, if none has been selected yet
if($cont_id eq ""){initial_list()}

sub initial_list {
  # this function creates the initial Description of custom
  # the user may then select a company and reexecute the script for more details

  my %hash;
  foreach my $line (@custrc){
  $hash{$line->[0]}=$line->[1];
  }

  print "<table border=0><tr><td id=t2>Beschreibung<br><br></td></tr>";
  foreach my $key (keys(%hash)){
     my $value = $key;
     $value =~ s/\s/%20/g;

    print "<tr><td><a href=/cgi-bin/admin/kundenvalue.cgi?name=$hash{$key}&value=$value>$key</a></td></tr>";

  }
  print "</table></body></html>";

 exit;
}



edit pq: code-tags hinzugefügt\n\n

<!--EDIT|pq|1114171429-->

View full thread Perl/cgi: Datenbank