Educational Purpose: Connect PHP code to Weather API
$10-30 AUD
Paid on delivery
Already have the code and just need this fixed, I have the API key in the code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My Weather</title>
</head>
<body>
<p> are you comfortable with php? question</p>
<?php
$conn = new mysqli("localhost","root","","ia3weather") or die(mysqli_error($conn));
$query = mysqli_query($conn, "SELECT * FROM stations ORDER BY name ASC") or die(mysqli_error($conn));
echo '<form action="'.htmlentities($_SERVER['PHP_SELF']).'" method="get">';
echo '<select name="wmo" onchange="[login to view URL]()">';
echo '<option value="00000">Select Station</option>';
if (isset($_GET['wmo'])) {
$wmo = $_GET['wmo'];
} else {
$wmo = '00000';
}
while ($row = mysqli_fetch_array($query)) {
if ($row['wmo'] == $wmo) {
$selected = ' selected ';
} else {
$selected = ' ';
}
echo '<option value="'.$row['wmo'].'"'.$selected.'>'.$row['name'].'</option>';
}
echo '</select> ';
echo '</form>';
if ($wmo != '00000') {
$query = mysqli_query($conn, "SELECT * FROM stations WHERE wmo=$wmo") or die(mysqli_error($conn));
while($row = mysqli_fetch_array($query)) {
echo '<a href="[login to view URL]@'.$row['lat'].','.$row['lon'].',14z" target=\"_blank\">Map</a>';
echo '<p>Name: '.$row['name'].'</p>';
}
$query=mysqli_query($conn, "SELECT * FROM observations WHERE wmo='$wmo' ORDER BY datetime DESC LIMIT 5") or die(mysqli_error($conn));
while ($row = mysqli_fetch_array($query)) {
echo $row['datetime'].': '.$row['air_temp'].'<br>';
}
$places = array("94578"=>"Brisbane", "95551"=>"Toowoomba", "94578"=>"Logan");
$url = '[login to view URL]'.$places["$wmo"];
$result = file_get_contents($url);
$json = json_decode($result, true);
echo 'Maximum tomorrow: '.$json["forecast"]["forecastday"][1]["day"]["maxtemp_c"];
/*
$url = '[login to view URL]'. $places["$wmo"];
$xml = simplexml_load_file($url);
echo 'Maximum tomorrow:'.$xml->forecast->forecastday[1]->day->maxtemp_c;
*/
}
?>
</body>
</html>
Project ID: #35098215
About the project
7 freelancers are bidding on average $26 for this job
✔️Hi there✔️ this is tyler i have interesting your project I 100% guarantee that I will help you and make you satisfied. Because, I just worked on a project very similar to yours. As a senior web developer, I've exper More
Hello friend As I am senior web developer, I am confident on your project I can start right now ,and I can satisfy your requirements. Thanks