Schrift
[thread]482[/thread]

Perl/cgi: Datenbank



<< >> 3 Einträge, 1 Seite
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-->
Relais
 2005-04-22 13:07
#4865 #4865
User since
2003-08-06
2244 Artikel
ModeratorIn
[Homepage] [default_avatar]
Und wie sieht das dazugehörige "kundenvalue.cgi" aus?
Was hast Du probiert und was macht Dir dabei Schwierigkeiten?
Erst denken, dann posten --
26. Deutscher Perl- u. Raku -Workshop 15. bis 17.04.2024 in Frankfurt/M.

Winter is Coming
pq
 2005-04-22 16:03
#4866 #4866
User since
2003-08-04
12208 Artikel
Admin1
[Homepage]
user image
Wiki:Wie frage ich bei Perl-Community.de?, insbesondere Code-Tags
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wiki:Wie frage ich & perlintro Wiki:brian's Leitfaden für jedes Perl-Problem
<< >> 3 Einträge, 1 Seite



View all threads created 2005-04-22 12:42.