-
Notifications
You must be signed in to change notification settings - Fork 0
/
block.php
44 lines (43 loc) · 1.39 KB
/
block.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
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<link rel="stylesheet" href="./css/all.css" />
<script>
<?php
$json = 'data/test.json';
$data = json_decode(file_get_contents($json), true);
$bnum = $data["block"];
for ($i = 1; $i <= count($bnum); $i++) {
echo "function sb$i() {
var element = document.getElementById('block$i');
window.location = 'pages/block/$i.html';
}\n";
}
?>
</script>
</head>
<body>
<div class="block">
<div class="title">
<h3>方块</h3>
</div>
<div class="main">
<div class='grid-container'>
<?php
$json = 'data/test.json';
$data = json_decode(file_get_contents($json), true);
for ($i = 1; $i <= count($bnum); $i++) {
$img = $data['block'][$i]['imge'];
$name = $data['block'][$i]['zhname'];
echo "
<div class='grid-item' id='block$i' onclick='sb$i()'>
<img src='$img'>
<p>$name</p>
</div>
";
}
?>
</div>
</div>
</div>
</body>