-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathprint.php
More file actions
75 lines (68 loc) · 1.82 KB
/
Copy pathprint.php
File metadata and controls
75 lines (68 loc) · 1.82 KB
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
<!doctype html>
<html lang="ru">
<head>
<meta charset="UTF-8" />
<title>Отчёт для печати</title>
<meta name="description" content="Отчёт для печати" />
<meta name="Keywords" content="ОТЧЁТ, ПЕЧАТЬ" />
<link rel="stylesheet" href="style/print.css" />
<link rel="shortcut icon" href="image/favicon2.ico" type="image/x-icon" />
</head>
<body>
<header>
<h3> </h3>
</header>
<content>
<main>
<form action="" method="get">
<table class="c2">
<tr>
<td class="c2">Печать таблицы<br />myarttable из MySQL<br /></td>
</tr>
</table>
<table>
<tr class="cH">
<?php
// блок инициализации
try {
$pdoSet = new PDO('mysql:dbname=test;host=localhost', 'root', '');
$pdoSet->query('SET NAMES utf8;');
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
// название столбцов.
$sql = "SHOW COLUMNS FROM myarttable";
//echo $sql;
$stmt = $pdoSet->query($sql);
$resultMF = $stmt->fetchAll();
//var_dump($resultMF);
for ($iR = 0; $iR < Count($resultMF); ++$iR) {
?><td><?php echo $resultMF[$iR]["Field"];?></td><?php
}
?>
</tr>
<?php
$sql = "SELECT * FROM myarttable WHERE id>14 ORDER BY id ASC"; // ASC - по возрастанию; DESC - по убыванию.
//echo $sql;
$stmt = $pdoSet->query($sql);
$resultMF = $stmt->fetchAll();
//var_dump($resultMF);
for($iC=0; $iC<Count($resultMF); $iC++) {
?><tr><?php
$iCountLine = floor(Count($resultMF[$iC])/2);
for($iR = 0; $iR < $iCountLine; ++$iR) {
?><td><?php echo $resultMF[$iC][$iR];?></td><?php
}
?></tr><?php
}
?>
</table>
</form>
</main>
</content>
<footer>
<div> </div>
</footer>
</body>
</html>