table-generator
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
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
<?php
$ppp = 2;
$col = 4;
$td_title = array();
$td_picture = array();
$td_descript = array();
$id = array();
$counter = 0;
while($counter <= 9) {
array_push($td_title, 'naam'.$counter);
array_push($td_picture, 'picture'.$counter);
array_push($td_descript, 'description'.$counter);
array_push($id, 'id'.$counter);
$counter++;
}
$waarden = count($td_title);
$minrijen = ceil($waarden/$col);
$maxrijen = ceil($ppp/$col);
if($minrijen <= $maxrijen) {
$rijen = $minrijen;
}
else {
$rijen = $maxrijen;
}
echo "\n".'<table width="100%" border="1" cellspacing="0" cellpadding="0">';
echo "\n\t".'<tr>';
$cntr = 0;
for($i = 0; $i <= $rijen--; $i++) {
for($i2=0; $i2 <= $col-1; $i2++) {
echo "\n\t\t".'<td>';
if(isset($td_title[($i*$col)+$i2]) && ($i*$col)+$i2 < $ppp) {
echo $td_title[($i*$col)+$i2];
}
echo '</td>';
}
echo "\n\t".'</tr>';
echo "\n\t".'<tr>';
echo "\n\t\t".'<td> </td>';
echo "\n\t".'</tr>';
echo "\n\t".'<tr>';
$cntr++;
}
echo "\n\t\t".'<td></td>';
echo "\n\t".'</tr>';
echo "\n".'</table>';
?>
$ppp = 2;
$col = 4;
$td_title = array();
$td_picture = array();
$td_descript = array();
$id = array();
$counter = 0;
while($counter <= 9) {
array_push($td_title, 'naam'.$counter);
array_push($td_picture, 'picture'.$counter);
array_push($td_descript, 'description'.$counter);
array_push($id, 'id'.$counter);
$counter++;
}
$waarden = count($td_title);
$minrijen = ceil($waarden/$col);
$maxrijen = ceil($ppp/$col);
if($minrijen <= $maxrijen) {
$rijen = $minrijen;
}
else {
$rijen = $maxrijen;
}
echo "\n".'<table width="100%" border="1" cellspacing="0" cellpadding="0">';
echo "\n\t".'<tr>';
$cntr = 0;
for($i = 0; $i <= $rijen--; $i++) {
for($i2=0; $i2 <= $col-1; $i2++) {
echo "\n\t\t".'<td>';
if(isset($td_title[($i*$col)+$i2]) && ($i*$col)+$i2 < $ppp) {
echo $td_title[($i*$col)+$i2];
}
echo '</td>';
}
echo "\n\t".'</tr>';
echo "\n\t".'<tr>';
echo "\n\t\t".'<td> </td>';
echo "\n\t".'</tr>';
echo "\n\t".'<tr>';
$cntr++;
}
echo "\n\t\t".'<td></td>';
echo "\n\t".'</tr>';
echo "\n".'</table>';
?>