Educational Purpose: Connect PHP code to Weather API

Completed Posted 1 year ago Paid on delivery
Completed 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>

PHP MySQL JavaScript HTML API

Project ID: #35098215

About the project

7 proposals Remote project Active 1 year ago

Awarded to:

tariqs028

Hi, Ready to start working on your project. I have read your requirements of your project and have expertise in this project related things. I have to discuss something with you related to this project. Let's discuss More

$10 AUD in 1 day
(43 Reviews)
5.2

7 freelancers are bidding on average $26 for this job

caciocode

Hi, I am a PHP developer. I can make changes and fix issues in your PHP code.

$20 AUD in 1 day
(379 Reviews)
7.2
tyleleerking

✔️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

$30 AUD in 1 day
(18 Reviews)
4.6
Jarretdev

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

$30 AUD in 1 day
(10 Reviews)
4.5
minqunshao

Hello I checked your code and can perfectly fix. thanks......

$30 AUD in 1 day
(9 Reviews)
5.2