Jump to content

Need Help with showing all postcodes from a DB into Google Maps


snowymasta

Recommended Posts

Hi there, 

So the below code is working for 1 entry, however there is 2 entries in the database which are different postcodes and I cannot get to show in Google Maps. When I do it without Mysql and just do it direct it works, but really want to do it from MYSQL - both postcodes are valid and tested as well.

 

<?php
$sql4 = "SELECT * FROM MK_migration_details";
$result4 = $conn->query($sql4);
?>


function initialize() {
        geocoder = new google.maps.Geocoder();
        var latlng = new google.maps.LatLng(40.768505,-111.853244);
        var myOptions = {
			mapTypeControl: false,
			fullscreenControlOptions: false,
			zoom: 8,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
			        }
        
		map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
   <?php     
		while($row4 = $result4->fetch_assoc()) {
  
			$mig_postcode = $row4["postcode"];	
				
		}		
				echo 'addPostCode("'.$mig_postcode.'")';
				
?>
   
	}
	

I know the issue lies with the PHP / Mysql Loop and the Javascript element 'addpostcode' when I put into the loop does not work, but works for a single address outside the loop.

 

Really appreciate your help guys!

 

Thanks you

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.