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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:26:28+00:00 2026-06-12T10:26:28+00:00

Connection.php file which stored database connection code with json: <?php $username = root; $password

  • 0

Connection.php file which stored database connection code with json:

<?php
    $username = "root";
    $password = "";
    $database = "roadmap";
    $url = "localhost";

    $con = mysql_connect($url, $username , $password);
    if (!$con) {
       die('Could not connect:' . mysql_error());
    }

    mysql_select_db($database, $con) ;
    $data = array();
    // query your DataBase here looking for a match to $input
    $query = mysql_query("SELECT * FROM students");
    while ($row = mysql_fetch_assoc($query)) {
       $json = array();
       $json['Id'] = $row['Id'];
       $json['Lon'] = $row['Lon'];
       $json['Lat'] = $row['Lat'];
       $data[] = $json;
    }
    header("Content-type: application/json");
    echo json_encode($data);
    mysql_close($con);
?>

In separate file index.php:

$.getJSON("connection.php", function(data) {
    addMarker( data[0].Lon,data[0].Lat ,data[0].desc);
    addMarker(-0.13264,51.50918 , );
    addMarker( -0.12498,51.50807 , );
    center = bounds.getCenterLonLat();
    map.setCenter(center, map.getZoomForExtent(bounds) - 1);
    zoom = map.getZoom();   
});

this currently pulls the json data through and I have to use it for each individual assigning of a part from the database such as data[0].lon will get the longitude entry for the first record with in the database.

As I am going to be working with quite a few entry’s. I want to loop through the json array and then out put all records as so:

addMarker( RECORD 1 );

addMarker( RECORD 2 );

addMarker( RECORD 3 );

Can anyone help me with this.

  • 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-12T10:26:29+00:00Added an answer on June 12, 2026 at 10:26 am

    use something like this

    $.each(data, function(i,row){
      addMarker( row['Lon'],row['Lat'] ,row['desc'])
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<?php class test_class { public function __construct() { } public function doLogin($username,$password) { include(connection.php);
I want to store my database connection information in a single file, which both
I have created a class file database.php which handles all the sql queries and
i use a file ( ss-config.php ) which contains informations about servor and database
I'm including the MySQLi connection file in the constructor of a PHP class. Since
MySQL connection in PHP can be established in two ways: $mysql = new mysqli('localhost',
What is the best way to handle mysql database users connection in PHP? I
I have a single PHP file which handles credit card processing. It starts as
I have a php file which connects to a MySql db and read the
I have an index.php, which at it's very start includes db.php - file which

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.