PHP - Best Way To Get Temperature Readings By U.s. City
I am looking for the easiest way to get live data for the current temperature for various U.S. cities. I just need to capture the data and display on the page. Any recommendations?
Similar TutorialsIn my registration form there are many form elements to give users' details for registration in my web site. among those elements there are two select boxes for user to select their district and city. I have created these two select box using ajax. Therefor a user select a district then automatically ajax creating second select box for cities is populating. I used separate php page called findcity.php to create city select box. I called this findcity.php page from my original register.php page through onChange attribute. and there I passed the district id with the url to findcity.php page. like wise, Now I need to bring city id to my original register.php page when user select a city from city select box in findcity.php page. my problem is that. I tried to get city Id to register.php page but still I couldn't get it. city id is needed me to send to the database with other form elements' values. can anybody help me to fix my problem? here is my coding for your reference. This code is, from my register.php page Code: [Select] <div> <label for="district">District <img src="../images/required_star.png" alt="required" /> : </label> <?php require_once ('../includes/config.inc.php'); require_once( MYSQL2 ); $query="select * from district order by district_id"; $result = mysqli_query( $dbc, $query); echo '<select name="district" class="text" onChange="getCity(' . "'" . 'findcity.php?district=' . "'" . '+this.value)">'; echo '<option value="">-- Select District --</option>'; while( $row = mysqli_fetch_array($result, MYSQLI_NUM)) { echo '<option value="' . $row[0] . '"'; // Check for stickyness: if ( isset( $_POST['district']) && ( $_POST['district'] == $row[0] )) echo ' selected="selected"'; echo " >$row[1]</option>"; } echo '</select>'; ?> </div> <div> <label for="city">City <img src="../images/required_star.png" alt="required" /> : </label> <input type="hidden" name="reg_locationid" id="reg_locationid" value="56" /> <div id="citydiv" style="position: relative; top: -14px; left: 130px; margin-bottom: -26px;"> <select name="city" class="text"> <option>-- Select City --</option> </select> </div> </div> this is, from my findcity.php page Code: [Select] <?php $districtId=$_GET['district']; require_once ('../includes/configaration.inc.php'); require_once( MYSQLCONNECTION ); $query="select city_id, city_name from city2 where district_id=$districtId"; $result=mysqli_query( $dbc, $query); echo '<select name="city" class="text"> <option>-- Select City --</option>'; while($row=mysqli_fetch_array($result, MYSQLI_NUM)) { echo '<option value="' . $row[0] . '"'; // Check for stickyness: if ( isset( $_POST['city']) && ( $_POST['city'] == $row[0] )) { echo ' selected="selected"'; //echo '<input type="hidden" name="city" value="' . $row[0] . '"'; } echo " >$row[1]</option>"; } echo '</select>'; ?> Is there a way to auto populate someone's city by zipcode? Also is it possible to find out their county as well? This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=359321.0 Greetings, Well i have a registration function in my website. User chooses his city of residence. Now all i need is to find the neighbouring city of the city he specifies while registering. This is required for the cities outside US and Canada [For these two we can use zip codes to find neighbouring cities.]. Is it possible to find neighbouring cities for cities of other countries?? Thanks ok guys, i know you guys are awesome and I always get the help and I need some help in figuring the current city and the metropolitan area from an ip address. For example, if I am in Harlem, NY, I need to get the Harlem and New York. I have a code that is partially working but not accurate enough, please guys help, something like groupon will do. Code: [Select] function currentCity () { ( ( (float)phpversion() < 5.3 ) ) ? die ( 'There is something wrong!' ) : ''; $site = file_get_contents( "http://www.google.com/search?q=VBXMCBVFKJSHDKHDKF" ); $getLocationViaGoogle = function ( $html ){ $regex = "#<\w+\s\w+=\"tbos\">([^<]{3,})<\/\w+>#i"; preg_match_all( $regex, $html, $matches ); return $matches[1][0]; }; print $getLocationViaGoogle( $site ); } I have a problem with the following code but i really don't see it: I try to populate the city textfield by the zipcode entered on the zipcode textfield function fillcitystate(controlname) { var zipstring = ""; xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", "postcode.php?postcode=" + controlname.value, true); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { var zipstring = xmlhttp.responseText; if (zipstring!="Error") { var ziparray = zipstring.split("|"); document.getElementById("test").innerHTML = ziparray[1]; } } } xmlhttp.send(null); } In postcode.php $returnval = "Error"; $postcode = $_GET['postcode']; $query = "SELECT * FROM city WHERE code='$postcode'"; $resultval = mysql_query($query); $rowcount = mysql_num_rows($resultval); if ($rowcount==1) { $row = mysql_fetch_array($resultval); $returnval = $row['code']."|".ucwords(strtolower($row['name']))."|".$row['province']; } else { } echo $returnval; When entering a zipcode, nothing happened so i decided to just echo the name of the city using the innerHTML. Still nothing happened, so i commented out all the php in my postcode.php and decided to just do: $postcode = $_GET['postcode']; echo $postcode; then it printed out: 'undefined' Can somebody point me out? |