-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeather.php
More file actions
64 lines (62 loc) · 2.08 KB
/
Copy pathWeather.php
File metadata and controls
64 lines (62 loc) · 2.08 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
<?php
$api_url = 'https://samples.openweathermap.org/data/2.5/forecast?id=524901&appid=b6907d289e10d714a6e88b30761fae22/';
$forecast = json_decode(file_get_contents($api_url));
?>
<html>
<head>
<h1 align="center"> Coding Test </h1>
<style>
table {
width:100%;
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 15px;
text-align: left;
}
table#t01 tr:nth-child(even) {
background-color: #eee;
}
table#t01 tr:nth-child(odd) {
background-color: #fff;
}
table#t01 th {
background-color: black;
color: white;
}
</style>
<h2 align="center">5 day weather forecast for Moscow, Russia</h2>
<p align="center">Values displayed below are for the time 18:00</p>
<table id="t01">
<tr>
<th></th>
<th><?php echo substr($forecast->list[0]->dt_txt, 0 ,10); ?></th>
<th><?php echo substr($forecast->list[8]->dt_txt, 0 ,10); ?></th>
<th><?php echo substr($forecast->list[16]->dt_txt, 0 ,10); ?></th>
<th><?php echo substr($forecast->list[24]->dt_txt, 0 ,10); ?></th>
<th><?php echo substr($forecast->list[32]->dt_txt, 0 ,10); ?></th>
</tr>
<tr>
<td> Max_temp </td>
<td> <?php echo $forecast->list[0]->main->temp_max - 273.15;?> </td>
<td> <?php echo $forecast->list[8]->main->temp_max - 273.15;?> </td>
<td> <?php echo $forecast->list[16]->main->temp_max - 273.15;?> </td>
<td> <?php echo $forecast->list[24]->main->temp_max - 273.15;?> </td>
<td> <?php echo $forecast->list[32]->main->temp_max - 273.15;?> </td>
</tr>
<tr>
<td> Humidiy </td>
<td> <?php echo $forecast->list[0]->main->humidity;?> </td>
<td> <?php echo $forecast->list[8]->main->humidity;?> </td>
<td> <?php echo $forecast->list[16]->main->humidity;?> </td>
<td> <?php echo $forecast->list[24]->main->humidity;?> </td>
<td> <?php echo $forecast->list[32]->main->humidity;?> </td>
</tr>
</table>
</html>
<footer>
<small>© Copyright 2019, Asfand Khan</small>
</footer>