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

  • Home
  • SEARCH
  • 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 4265204
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:35:31+00:00 2026-05-21T06:35:31+00:00

I have a php script to retrieve data from a MysQL databse following an

  • 0

I have a php script to retrieve data from a MysQL databse following an ajax call. The data needs to be returned to the calling web page as a string representing a series of x,y values to be displayed on a scatter graph.

The required format which the php script needs to output to the calling page (which will pick it up from xmlhttp.responseText) is as follows:

[[1,1],[2,2],[3,3],[4,4],[5,5],[6,6],[7,7]]

What I am getting is:

[[0,”69.08″],[1,”53.53″],[2,”61.61″],[3,”72.04″],[4,”82.72″],[5,”103.76″]]

The PHP code I am using to build the return string is:

while ($row=mysql_fetch_array($res_Data,MYSQL_NUM)) { 

  $index[$i] = $i;
  $PointArray[0] = $i;
  $PointArray[1] = $row[1];
  $ReturnData[$i] = $PointArray;
  $i = $i + 1;
}

echo json_encode($ReturnData);

Interestingly, when I echo the data to a html table displayed on the calling page rather than setting it as a php array, no double quotes appear.

My questions is twofold:

(1) Is there a more elegant way of building the data string than what I have come up with which appears a bit clumsy?

(2) What’s the best way to remove the double quotes – should this be done server side or in the javascript function on the web page initiating the call?

Many thanks

  • 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-21T06:35:32+00:00Added an answer on May 21, 2026 at 6:35 am

    If you don’t want quotes to appear – just don’t put a strings in array 😉

    Replace your code to something like (I added (float) modifier before $row[1]):

    while ($row=mysql_fetch_array($res_Data,MYSQL_NUM)) { 
    
      $index[$i] = $i;
      $PointArray[0] = $i;
      $PointArray[1] = (float)$row[1];
      $ReturnData[$i] = $PointArray;
      $i = $i + 1;
    }
    

    Or a little more compact:

    while ($row=mysql_fetch_array($res_Data,MYSQL_NUM)) { 
      $index[$i] = $i; // what is it used for?
      $ReturnData[$i] = array($i, (float)$row[1]);
      $i++;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php script which accesses a MSSQL2005 database, reads some data from
Hey guys I have an ajax jquery function that receives data from a php
I have a PHP script that needs to determine if it's been executed via
Working on an AJAX website (HTML,CSS,JavaScript, AJAX, PHP, MySQL). I have multiple javascript functions
what functions i have to use to encode/decode/escape/stripslash data for following purposes? when calling
I have a PHP script that runs as a CGI program and the HTTP
I have a PHP script that initialises an image gallery. It loops through all
I have a PHP script that can encode a PNG image to a Base64
I have a PHP script that sends critical e-mails. I know how to check
I have a PHP script that processes file uploads. The script tries to organise

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.