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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:48:19+00:00 2026-06-11T10:48:19+00:00

Basically I am creating a dynamic google map that pulls information from the database,

  • 0

Basically I am creating a dynamic google map that pulls information from the database, the connection is fine, the query is fine – but I’m unable to access my variables ($row) from my function.

Should I be parsing all the javascript from inside the php function itself? or can I have it static on my page and access the variables simply by calling the function (getCurrentMapData) directly above the javascript?

function getCurrentMapData( $select ) 
{
    global $mysqli;

    $sql = $mysqli->query($select);

    if(!$sql) {
       printf("%s\n", $mysqli->error);
       exit();
    }   

    $row = $sql->fetch_array(); 

}

And here’s our outset:

<?php

    $select = "SELECT `id`, `title`, `address`, `lat`, `lng`, `date` FROM `globalmap` ORDER BY `id` desc "; 

    getCurrentMapData( $select );

?>

                <h3>
                    I'm Currently Playing @ 
                <?php echo $row['title'] ?>
                </h3>
                <div id="map">
                    <div id="ps_map_1" class="mapCon">
                    </div>
                </div>
                <script src="http://maps.google.com/maps/api/js?sensor=false"></script> <script>
                    // <![CDATA[


                        var psGlobals = {
                            address: "<?php echo $row['address'] ?>",
                            lat: <?php echo $row['lat'] ?>,
                            lon: <?php echo $row['lng'] ?>,
                            zoomlevel: 13
                        };

                        function initialize() 
                        {
                            psGlobals.latlng = new google.maps.LatLng(psGlobals.lat, psGlobals.lon);
                            buildMap();
                            psGlobals.dirRenderer = new google.maps.DirectionsRenderer();
                            psGlobals.dirService = new google.maps.DirectionsService();
                        }

                        function buildMap()
                        {
                            var myOptions, marker;
                            myOptions = {
                                  navigationControl: true,
                                  navigationControlOptions: {
                                      style: google.maps.NavigationControlStyle.ZOOM_PAN
                                    },

                                  mapTypeControl: true,
                                  scaleControl: false,
                                  zoom: psGlobals.zoomlevel,
                                  center: psGlobals.latlng,
                                  mapTypeId: google.maps.MapTypeId.HYBRID
                            };
                            psGlobals.map = new google.maps.Map(document.getElementById("ps_map_1"), myOptions);
                            psGlobals.marker = new google.maps.Marker({
                                position: psGlobals.latlng, 
                                map: psGlobals.map,
                                title: "<?php echo $row['title'] ?>"
                            });

                        }

                        $(document).ready(function(){
                            initialize()
                        });

                    // ]]>

                    </script>           
  • 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-06-11T10:48:21+00:00Added an answer on June 11, 2026 at 10:48 am

    You should return the fetched array

    function getCurrentMapData( $select )  
    { 
        global $mysqli; 
    
        $sql = $mysqli->query($select); 
    
        if(!$sql) { 
           printf("%s\n", $mysqli->error); 
           exit(); 
        }    
    
        return $sql->fetch_array();  
    
    } 
    

    Then you should assign the result of this function to the $row variable

    $row = getCurrentMapData($select);

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

Sidebar

Related Questions

I am creating a database application that provides dynamic views of any database. For
Basically I am creating a database driven website in Web Developer 2008. The database
I just need help. Basically I am creating a windows appllication that sends bulk
Basically, I am creating an XML file by taking the values from a column
I am creating an application that basically places a drawable into an imageView onClick.
So i have been creating this framework thing that basically puts together source code
I am basically creating an API in php, and one of the parameters that
I have been given a new task from the client which is basically creating
Basically, I am creating a dynamic 2d ArrayList. private ArrayList<char[]> myArray; This code below
I have built a 'dynamic' site. Basically, there is a configuration database, where users

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.