Leser: 2
|< 1 2 >| | 18 Einträge, 2 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
while(my ($ort,$name) = $sth -> fetchrow_array){
push @ort,$ort;
push @name,$name;
if ( $count > 0 && $count % 2 == 0 ) {
print qq{</tr><tr >};
}
print qq {
<td>
# etc $ort
</td>
};
$count++;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
my $template = HTML::Template->new(filename => 'deneme.html');
my (@ergebnisse);
while(my @result = $sth->fetchrow_array()){
my %hash = (
ort => $result[0],
name => $result[1],
);
push(@ergebnisse,\%hash);
}
$template->param(ABFRAGE => \@ergebnisse);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<table width="75%" border="1" bordercolor="#0000FF">
<tmpl_loop name="ABFRAGE">
<tr>
<td><table width="75%" border="1" align="center" bordercolor="#FF0000">
<tr>
<td><tmpl_var name="ort"></td>
</tr>
<tr>
<td><tmpl_var name="name"></td>
</tr>
</table></td>
<td><table width="75%" border="1" align="center" bordercolor="#FF0000">
<tr>
<td><tmpl_var name="ort"></td>
</tr>
<tr>
<td><tmpl_var name="name"></td>
</tr>
</table></td>
</tr>
</tmpl_loop name="ABFRAGE">
</table>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
while(my ($ort,$name) = $sth -> fetchrow_array){
push @ort,$ort;
push @name,$name;
if ( $count > 0 && $count % 2 == 0 ) {
print qq{</tr><tr >};
}
pirnt qq {
<td><table width="75%" border="1" align="center" bordercolor="#FF0000">
<tr>
<td><tmpl_var name="$ort"></td>
</tr>
<tr>
<td><tmpl_var name="$name"></td>
</tr>
</table></td>
};
$count++;
}
1
2
3
4
5
6
schleifeX =>
[
{ schleifeY => [ {inhalt => 'a'}, {inhalt => 'b'} ] },
{ schleifeY => [ {inhalt => 'c'}, {inhalt => 'd'} ] },
{ schleifeY => [ {inhalt => 'e'}, {inhalt => 'f'} ] },
];
1
2
3
4
5
6
7
8
9
<table>
<!-- TMPL_LOOP NAME=schleifeX -->
<tr>
<!-- TMPL_LOOP NAME=schleifeY -->
<td><!-- TMPL_VAR NAME=inhalt --></td>
<!-- /TMPL_LOOP -->
</tr>
<!-- /TMPL_LOOP -->
</table>
1
2
3
4
5
6
schleife =>
[
{inhalt => 'a'}, {inhalt => 'b', next => 1},
{inhalt => 'c'}, {inhalt => 'd', next => 1},
{inhalt => 'e'}, {inhalt => 'f', next => 1},
];
1
2
3
4
5
6
7
8
<table>
<tr>
<!-- TMPL_LOOP NAME=schleife -->
<td><!-- TMPL_VAR NAME=inhalt --></td>
<!-- TMPL_IF NAME=next --></tr><tr><!-- /TMPL_IF -->
</tr>
<!-- /TMPL_LOOP>
</table>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
chdir("../../pics");
my(@bilder,@ergebnisse);
push (@bilder, glob "*.jpg");
push (@bilder, glob "*.gif");
foreach my $bild(@bilder){
my %hash = (
schleifeX =>
[
{ schleifeY => [ {inhalt => '$bild'} ] },
]
);
push(@ergebnisse,\%hash);
}
$template->param(schleifeX => \@ergebnisse);
1
2
3
4
5
6
7
8
9
<table>
<!-- TMPL_LOOP NAME=schleifeX -->
<tr>
<!-- TMPL_LOOP NAME=schleifeY -->
<td><img src="../../pics/><!-- TMPL_VAR NAME=inhalt -->"</td>
<!-- /TMPL_LOOP -->
</tr>
<!-- /TMPL_LOOP -->
</table>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
my @files = glob("*.jpg");
my $width = 3;
my @images = ();
for my $i (0..$#files) {
if ($i % $width == 0) { # new row, append to dimension X
push (@images, { schleifeY => [ { inhalt => $files[$i] } ] } );
}
else { # new column, append to dimension Y
push (@{ $images[-1]->{schleifeY} }, { inhalt => $files[$i] } );
} # else
} # for
$template->param(schleifeX => \@images);
1
2
3
4
5
6
7
my $row = -1;
for my $i (0..$#files) {
my $modulo = $i % $width;
$row++ if 0 == $modulo; # start a new row
$images[$row]->{schleifeY}->[$modulo]->{inhalt} = $files[$i];
} # for
|< 1 2 >| | 18 Einträge, 2 Seiten |