<?php
$request = 'http://api.openweathermap.org/data/2.5/group?id=4880731,5000598,5128581,5368361,4887398,5391811,4930956,1275339,1273294,1275004,1264527,524901,703448,2643743,1816670,292223&APPID=ea2cc999e9e272185de78f08e2e738fc';
$response = file_get_contents($request);
$data=json_decode($response,true);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset = "UTF-8" />
<meta name="author" content="Chaitanya" />
<meta name="keywords" content="countries, country id" />
<link rel="stylesheet" type="text/css" href="style.css" />
<title>PHP Application</title>
</head>
<body>
<div class = "main-wrap">
<h2>PHP Web Assignment Task</h2>
<hr /><br />
<form action="index.php" method="post">
<pre>Name: <input type="text" name="name"/> Country: <input type="text" name="country"> <input type="submit" name="filter" value="Filter"></pre>
<br><br>
</form>
Search Term:<br />
<pre>Name: <?php echo $_POST['name']; ?>
Country: <?php echo $_POST['country']; ?>
</pre>
<br />
<table border="1" cellspacing="5" width="100%" style="text-align: center">
<tr>
<th>ID</th>
<th>Name</th>
<th>Country</th>
</tr>
<?php
$count = $data['cnt'];
$country;
if($_POST['filter']){
if($_POST['country']){
$country = $_POST['country'];
for($i = 0; $i < $count; $i++){
if($data['list'][$i]['sys']['country'] == $country){
echo "<tr>";
echo "<td>".$data['list'][$i]['id']."</td>";
echo "<td>".$data['list'][$i]['name']."</td>";
echo "<td>".$data['list'][$i]['sys']['country']."</td>";
echo "</tr>";
}
else continue;
}
}
if ($_POST['name']) {
$name = $_POST['name'];
for($i = 0; $i < $count; $i++){
if($data['list'][$i]['name'] == $name){
echo "<tr>";
echo "<td>".$data['list'][$i]['id']."</td>";
echo "<td>".$data['list'][$i]['name']."</td>";
echo "<td>".$data['list'][$i]['sys']['country']."</td>";
echo "</tr>";
}
else continue;
}
}
}
else{
for($i = 0; $i < $count; $i++){
echo "<tr>";
echo "<td>".$data['list'][$i]['id']."</td>";
echo "<td>".$data['list'][$i]['name']."</td>";
echo "<td>".$data['list'][$i]['sys']['country']."</td>";
echo "</tr>";
}
}
?>
</table>
</div>
</body>
</html>
>
- Output for 7.0.0
- Parse error: syntax error, unexpected '<', expecting end of file in /in/ovOlB on line 9
Process exited with code 255. - Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.16
- Parse error: syntax error, unexpected '<' in /in/ovOlB on line 9
Process exited with code 255.
preferences:
157.9 ms | 1395 KiB | 24 Q