Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7559001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:31:18+00:00 2026-05-30T12:31:18+00:00

I am new to Javascript. I want to fetch lat-long from MySQL (more then

  • 0

I am new to Javascript. I want to fetch lat-long from MySQL (more then 100) and use it to add markers on Google Maps.

To do this I think i’ve to use php -server side programming. I am able to pass array from PHP to Javascript. Here it is

   <?
mysql_connect('localhost', 'username', 'pwd') or die(mysql_error()); 
echo "Connected to MySQL<br />";

mysql_select_db("pro_user") or die(mysql_error());

$result = mysql_query("SELECT * FROM info"); 
$no=count($result);
$i=0;
while($row = mysql_fetch_array( $result ))
{
    $a[$i]=$row['city'];
    $b[$i]=$row['loc_lat'];
    $c[$i]=$row['loc_long'];
    $i++;
}
  ?>
  <html> 
<head> 
    <script type="text/javascript"> 
    function initialize() 
{ 
    var latlng = new google.maps.LatLng(22.3038945, 70.8021599); 
    var myOptions = {
        zoom: 8, 
        center: latlng, 
        mapTypeId: google.maps.MapTypeId.ROADMAP 
    }; 
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); 

<?  for($i=0;$i<count($a); $i++)
    {
        echo "a[$i]='".$a[$i]."';\n";
        echo "b[$i]='".$b[$i]."';\n";
        echo "c[$i]='".$c[$i]."';\n";       

    } 
?>
    function createMarker(latitude,longitude,title) 
    { 
        var markerLatLng = new google.maps.LatLng(latitude,longitude);
        var marker = new google.maps.Marker({ position: markerLatLng, map: map, title: title }); 
    }
    createMarker(22.3038945, 70.8021599,'Gujarat');

for(i=0;i<a.length;i++)
    {   
        document.write(a[i]);
        document.write(b[i]);
        document.write(c[i]);

        initialize().createMarker(b[i], c[i], a[i]);
    }       

} 

    </script>
</head>
<body onload="getData()"></body>
    </html>

Now I am stuck. I am not able to pass Javascript array to make markers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T12:31:19+00:00Added an answer on May 30, 2026 at 12:31 pm

    There is a very simple tutorial on the google maps website for doing this using PHP / XML / MySQL and Javascript ….

    http://code.google.com/apis/maps/articles/phpsqlajax.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to javascript.I want to move a car on path with arrows.I
I am new to Javascript and am having some difficulty. I want to have
I'm brand spankin' new to Javascript. Here's what I want to do. I want
An example: getAppletContext().showDocument( new URL(javascript:alert(document.getElementById('textbox').value); )); Instead of alerting this textbox value, I want
If I want to try out something new in Ruby or Javascript, I love
I want it to have a popup dialog javascript box. Instead of a new
I m new to using Web services using JavaScript. All I want is to
I've such a situation , want to retrieve row ids from mysql to input
So I am still somewhat new to PHP, MySQL, and Javascript but I have
I have a form and I want to give an add more item link

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.