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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:10:49+00:00 2026-06-04T15:10:49+00:00

I am trying to get returned values from database from a PHP array to

  • 0

I am trying to get returned values from database from a PHP array to a JavaScript array.
So far what I’ve done is returning the values as a string and I want each value as an array
index.

This is my jQuery AJAX Call:

    $.ajax({
          type: 'GET',
          url: "Profile_Control.php",
          data:"ajaxRequest=yes&id="+document.getElementById("compid").value,
          success:function(data)
          {       
              document.getElementById("asd").innerHTML=data;
          }
        });

and this is my PHP script so far, which is returning the values like a string and I want each value in the array index.

   $branches=Profile_Model::getCompanyBranches($_GET['id']);

    while($row=mysql_fetch_array($branches))
    {
        echo $row[3];
    }

Now I am only echoing column 3 of the values returned from database and the output is like this:

        67.030867.020467.031167.020667.0357

and the result I want should be like this.

   arr[0]=67.0308
   arr[1]=67.0204
   arr[2]=67.0311
   arr[3]=67.0206
   arr[4]=67.0357

I also tried encoding the data in JSON by using json_encode($row[3]); but it returns me the following result.

  "67.0308""67.0204""67.0311""67.0206""67.0357"
  • 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-04T15:10:50+00:00Added an answer on June 4, 2026 at 3:10 pm

    Create an array with the elements you eventually want in your JS array and then json_encode that array:

    $rows = array();
    while($row=mysql_fetch_array($branches)) {
        $rows[] = $row[3];
    }
    echo json_encode($rows);
    

    However, data will be an array in your success callback so you cannot simply assign it to the innerHTML property of an element. But since that seems to be debug output simply replace it with console.log(data);.

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

Sidebar

Related Questions

So I'm trying to get the values from a SQLite database into a cursor,
I'm trying to get the returned value from a java method, but it returns
I am trying to get the rgb values from a CGColor I use the
I'm trying get values from a GridView using the following code: foreach (GridViewRow row
I'm trying to get a hold of the data returned from getJSON, but I
I'm trying to get some aggregate values from different tables, but my problem is
I am trying to get some errors returned in JSON format. So, I made
I am trying get all html links within a string and replace them using
I am trying get all html links within a string and replace them using
Trying to get parameters from a PUT request using HttpServlet#doPut: public void doPut(HttpServletRequest request,

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.