Informatie naast en onder elkaar
Ik ben bezig met een fotoalbum. Nu wil ik graag dat als er 4 foto's naast elkaar staan (de thumps) er automatisch naar een nieuwe regel word gesprongen. Ook als hier weer 4 foto's naast elkaar staan, naar de volgende regel, enzo enzo.
Kan iemand mij hier bij helpen ?
BIJV:
FOTO 1 FOTO 2 FOTO 3 FOTO 4
FOTO 5 FOTO 6 FOTO 7 FOTO 8
FOTO 9 FOTO 1 FOTO 11
zet een teller in je loop, bij 4 zet je je teller naar 1 terug, en geef je een <tr>
Bedankt in iedergeval de mensen die me hebben proberen te helpen!
groeten,
de mensen die je hebben getracht te helpen
cq
moi
Code (php)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
$x=3; //images near eachother on a page.
$y=4; //images above eachother on a page.
$size_x=160; //size images horizontal in pixels
$size_y=120; //size images vertical in pixels
$thumb_dir='thumbnails'; //directory for the thumbnails
//resize function
function resize($filename, $dest, $width, $height, $type=''){
if(@imagecreatefromgif($filename)){
$img=imagecreatefromgif($filename);
$type_r='gif';
}
elseif(@imagecreatefromjpeg($filename)){
$img=imagecreatefromjpeg($filename);
$type_r='jpg';
}
elseif(@imagecreatefrompng($filename)){
$img=imagecreatefrompng($filename);
$type_r='png';
}
elseif(@imagecreatefromwbmp($filename)){
$img=imagecreatefromwbmp($filename);
$type_r='bmp';
}
else{
return 'Cannot open file';
}
$type=($type=='')?$type_r:'';
$img_n=imagecreatetruecolor ($width, $height);
imagecopyresampled($img_n, $img, 0, 0, 0, 0, $width, $height, imagesx($img), imagesy($img));
if($type=='gif'){
imagegif($img_n, $dest);
}
elseif($type=='jpg'){
imagejpeg($img_n, $dest);
}
elseif($type=='png'){
imagepng($img_n, $dest);
}
elseif($type=='bmp'){
imagewbmp($img_n, $dest);
}
Return true;
}
$a=0;
$pc=0; //picture counter
$row=0; //row counter
print'
<html>
<head>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p><h1><center>Picture Viewer</center></h1></p>
';
print'<table cellpadding="2" cellspacing="2" border="0" width="100%">';
//check directory $thumb_dir exists!
$search_dir='.';
$dp = opendir ($search_dir);
while($item=readdir($dp) AND $a!=1){
if((is_dir($item)) AND (substr($item,0,1)!='.')){
if($item == $thumb_dir){$a=1;}
}
}
if(!$a==1){mkdir($thumb_dir);
}
//show thumbnails
if(!isset($_GET['start'])){$start=0;
}else{$start=$_GET['start'];
}
$search_dir='.';
$dp=opendir($search_dir);
rewinddir($dp);
$a=0; //images/page counter
while($item=readdir($dp)){
if((is_file($item))AND(substr($item,0,1)!=';')){
if(eregi('()(.jpg|.png|.gif)$',$item)){ //show files. .jpg/.png/.gif
//create the thumbnail picture pad/name
$thumb="$thumb_dir/$item";
//check if the thumbnail already exist, if not, create one!
if(!file_exists($thumb)){resize($item, $thumb, $size_x, $size_y);
}
$pc=$pc+1; //general picture counter
if($pc > 0+$start AND $pc <= $x*$y+$start){
$a=$a+1;
print'
<td><a href="'.$item.'" target="_self"><img src="'.$thumb.'" width="'.$size_x.'" height="'.$size_y.'"></a></td>
';
if($a==$x){
$a=0;
$row=$row+1;
print'</tr><tr>';}
}
}
}
}
print'</tr>';
print'</table></p>';
closedir($dp);
//counting for next pages
if(!isset($_GET['start'])){$start=$x*$y;
}else{$start=$_GET['start']+$x*$y;
}
$pg=0;
echo'<center>';
while($pc > $pg*$x*$y){
$start=$pg*$x*$y;
$view=$pg+1;
if($start==$_GET['start']){print'<a href="index.php?start='.$start.'"><font color="red"><b>'.$view.'</b></font></a> | ';
}else{
print'<a href="index.php?start='.$start.'">'.$view.'</a> | ';
}
$pg=$pg+1;
}
//page end
echo'</center>';
echo'</body>';
echo'</html>';
?>
$x=3; //images near eachother on a page.
$y=4; //images above eachother on a page.
$size_x=160; //size images horizontal in pixels
$size_y=120; //size images vertical in pixels
$thumb_dir='thumbnails'; //directory for the thumbnails
//resize function
function resize($filename, $dest, $width, $height, $type=''){
if(@imagecreatefromgif($filename)){
$img=imagecreatefromgif($filename);
$type_r='gif';
}
elseif(@imagecreatefromjpeg($filename)){
$img=imagecreatefromjpeg($filename);
$type_r='jpg';
}
elseif(@imagecreatefrompng($filename)){
$img=imagecreatefrompng($filename);
$type_r='png';
}
elseif(@imagecreatefromwbmp($filename)){
$img=imagecreatefromwbmp($filename);
$type_r='bmp';
}
else{
return 'Cannot open file';
}
$type=($type=='')?$type_r:'';
$img_n=imagecreatetruecolor ($width, $height);
imagecopyresampled($img_n, $img, 0, 0, 0, 0, $width, $height, imagesx($img), imagesy($img));
if($type=='gif'){
imagegif($img_n, $dest);
}
elseif($type=='jpg'){
imagejpeg($img_n, $dest);
}
elseif($type=='png'){
imagepng($img_n, $dest);
}
elseif($type=='bmp'){
imagewbmp($img_n, $dest);
}
Return true;
}
$a=0;
$pc=0; //picture counter
$row=0; //row counter
print'
<html>
<head>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p><h1><center>Picture Viewer</center></h1></p>
';
print'<table cellpadding="2" cellspacing="2" border="0" width="100%">';
//check directory $thumb_dir exists!
$search_dir='.';
$dp = opendir ($search_dir);
while($item=readdir($dp) AND $a!=1){
if((is_dir($item)) AND (substr($item,0,1)!='.')){
if($item == $thumb_dir){$a=1;}
}
}
if(!$a==1){mkdir($thumb_dir);
}
//show thumbnails
if(!isset($_GET['start'])){$start=0;
}else{$start=$_GET['start'];
}
$search_dir='.';
$dp=opendir($search_dir);
rewinddir($dp);
$a=0; //images/page counter
while($item=readdir($dp)){
if((is_file($item))AND(substr($item,0,1)!=';')){
if(eregi('()(.jpg|.png|.gif)$',$item)){ //show files. .jpg/.png/.gif
//create the thumbnail picture pad/name
$thumb="$thumb_dir/$item";
//check if the thumbnail already exist, if not, create one!
if(!file_exists($thumb)){resize($item, $thumb, $size_x, $size_y);
}
$pc=$pc+1; //general picture counter
if($pc > 0+$start AND $pc <= $x*$y+$start){
$a=$a+1;
print'
<td><a href="'.$item.'" target="_self"><img src="'.$thumb.'" width="'.$size_x.'" height="'.$size_y.'"></a></td>
';
if($a==$x){
$a=0;
$row=$row+1;
print'</tr><tr>';}
}
}
}
}
print'</tr>';
print'</table></p>';
closedir($dp);
//counting for next pages
if(!isset($_GET['start'])){$start=$x*$y;
}else{$start=$_GET['start']+$x*$y;
}
$pg=0;
echo'<center>';
while($pc > $pg*$x*$y){
$start=$pg*$x*$y;
$view=$pg+1;
if($start==$_GET['start']){print'<a href="index.php?start='.$start.'"><font color="red"><b>'.$view.'</b></font></a> | ';
}else{
print'<a href="index.php?start='.$start.'">'.$view.'</a> | ';
}
$pg=$pg+1;
}
//page end
echo'</center>';
echo'</body>';
echo'</html>';
?>