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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:52:11+00:00 2026-06-11T05:52:11+00:00

I am using codeigniter. Here is my php code to query result in array

  • 0

I am using codeigniter. Here is my php code to query result in array of obj then how can i pass them to js. I wanna use it in google maps

    <?php
    foreach ($query->result() as $row)
    {
        $lat = $row->geo_lat;
        $lng = $row->geo_lng;
        $pic = $row->picture;
        echo $lat;
        echo $lng;
        echo "<img src=\"" . base_url() . $pic . "\"/><br />";
        //echo json_encode($row);
        //echo "<pre>";
        //echo print_r($row);
    }
?>

Js code

var locations = ?????????;
var marker, i;
  for (i = 0; i < locations.length; i++) { 
    marker = new google.maps.Marker({
      position: new google.maps.LatLng(locations[i][0], locations[i][1]),
      map: map,
      draggable: true
    });
  }
  • 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-11T05:52:13+00:00Added an answer on June 11, 2026 at 5:52 am

    You can emit Javascript with PHP…why don’t you just JSON-encode all of the results and store them in your locations variable, like so:

    <?php 
        echo( "<script>" );
        echo( "  var locations = " + json_encode($query->result()) + ";" );
        echo( "</script>" );
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code here in PHP using Codeigniter framework, I can't seem to
I'm attempting to following the tutorials found here: http://www.ifadey.com/2010/06/crud-using-jquery-and-codeigniter/ My code is updated to
I am using CodeIgniter's anchor tag to generate links Here's the code I am
I'm using CodeIgniter 2.1 I use CodeIgniter's session to handle whether a user logged
I'm using CodeIgniter (a PHP framework) to build an app, and I have an
I'm using CodeIgniter a lot lately, with array methods for querying data: usually result_array()
Using Codeigniter, I am trying to get a php script to run after a
I am using CodeIgniter 1.7.1.Ok here is the scenario.When ever the form is submitted,i
I'm learning the OO and MVC paradigm (using Codeigniter and PHP). I continue to
i am using codeigniter library, and am stuck in a matter. first here's my

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.