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 577179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:07:33+00:00 2026-05-13T14:07:33+00:00

Hello Dear StackOverflowers, I am new to web programming and finding the server-client mixture

  • 0

Hello Dear StackOverflowers,

I am new to web programming and finding the server-client mixture confusing.
I have written very simple code which accepts a PHP 2D array [index][keys] (from a query) to just draw markers on a Google map (JavaScript). It works.
But it doesn’t look right to me!
Is this indeed the correct way to pass the values from my PHP array into the Javascript functions?

Thanks in advance
Ari


Edit for clarity again, added 4 spaces, thanks for the advice!

<head>

<meta http-equiv="content-type" content="text/html; charset=utf-8">

<title><?php echo $title;?></title

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=GoogleMapsKey"
type="text/javascript">

</script>

<script type="text/javascript"  language="JavaScript">

var m_map;

//Add one marker. 
function addmarker(iLat, iLon)
{ 
 var point = new GLatLng(iLat, iLon);
 m_map.addOverlay(new GMarker(point)); 
}


function initialize() 

{

if (GBrowserIsCompatible()) 
{

    m_map = new GMap2(document.getElementById("map_canvas"));
    m_map.setCenter(new GLatLng(37.4419, -122.1419), 1);
    m_map.setUIToDefault();

    <?php foreach($query as $item):?>

    var oLat = '<?php  echo $item['lat'];?>';
    var oLon = '<?php  echo $item['lon'];?>';

    addmarker(oLat, oLon);  

    <?php endforeach;?>

}
}// End initialize() 

</script>
</head>

<body onload="initialize()" onunload="GUnload()">
<div id="map_canvas" style="width: 500px; height: 300px"   ></div>
  • 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-13T14:07:33+00:00Added an answer on May 13, 2026 at 2:07 pm
    <?php 
    foreach($query as $item):?>
    
        var oLat = '<?php  echo $item['lat'];?>';
        var oLon = '<?php  echo $item['lon'];?>';
    
        addmarker(oLat, oLon);  
    
        <?php endforeach;?>
    

    The above code segment should provide following output if you have $query variable set as
    $query=array(array(‘lat’=>2,’lon’=>4),array(‘lat’=>5,’lon’=>6),array(‘lat’=>7,’lon’=>8),array(‘lat’=>9,’lon’=>1));


    var oLat = ‘2’;
    var oLon = ‘4’;

    addmarker(oLat, oLon);

    var oLat = ‘5’;
    var oLon = ‘6’;

    addmarker(oLat, oLon);

    var oLat = ‘7’;
    var oLon = ‘8’;

    addmarker(oLat, oLon);

    var oLat = ‘9’;
    var oLon = ‘1’;

    addmarker(oLat, oLon);

    Check you page html source.

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

Sidebar

Related Questions

Hello dear programmers, I am very new to android application development and for practice
Hello guys have client server chat and i try to write load test on
Hello dear Stackoverflowers ! I work on a CardDAV sync source for Android 2.3.3,
If I have two strings .. say string1=Hello Dear c'Lint and string2=Dear .. I
Hello i have this code var queue = new BlockingCollection<int>(); queue.Add(0); var producers =
For example I have the text. $text = 'Hello dear friend, my name is
Hello dear programmers, I have a requirement for creating a custom tableviewcell with a
Hello I have asp mvc view page, <%@ Page Language=C# Inherits=System.Web.Mvc.ViewPage<System.Drawing.Color[,]> %> how I
Hello dear friends of SO. I have this tables: PRECIOS +---------+--------+-----------+-------------+------------+ | priceID |
hello and good day dear xml-friends, i am new to xml so do not

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.