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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:07:30+00:00 2026-05-29T06:07:30+00:00

First I want to thank you guys here, because your posts have gotten me

  • 0

First I want to thank you guys here, because your posts have gotten me as close as I have been in the past week or so to resolve this; but I need help to finish this. I will admit, this process is still not clear in my mind and I am also exhausted to please bear with me

The script below has gotten me so close
What I need to accomplish: I need to grab some data from my db, stick it into an array and then access/use the
values in that array in my external javascript file. I’ll be using on the onload event.

<s c r i pt language="javascript1.2">
var arr = new array(<?php 
$result = mysql_query("select account_id, display_name, id from field where account_id = $holdAcctID and required_flag = 1");
$count = mysql_num_rows($result);
if($count>0){
  for( $i=0;$i<$count-1;$i++) {
    $row = mysql_fetch_row($result);
    echo $row[2],',';
  }
  $row = mysql_fetch_row($result);
  echo $row[2],',';
}
?>);
</s c r ipt>

above script produces this in my view source page:

<s c ript language="javascript1.2">
**var arr = new array(2860,2861,2862,2863,2864,3293,3294,3296,3521,3523,);**
</s c ript>

Q1 – how can i update the above array, so it holds the data from the same like the example below:
as you can see, it currently only holds, displays the id value

myReqField[0]
    [account_id] => 72
            [display_name] => Client Contact Name
            [id] => 2860
myReqField[1]
    [account_id] => 72
            [display_name] => Contact Phone
            [id] => 2888
myReqField[2]
        [account_id] => 72
            [display_name] => Email Address
            [id] => 2865
myReqField[3]
    [account_id] => 72
            [display_name] => Approval needed
            [id] => 2841

Q2 – how easy would it be to do this and place the results into a comma separate list. If fairly easy how would I code that and how can I access the list/value from my external javascript

Q3 – If Q2 is not possible/easy to set up, how then do I pull the array in to javascript file. Several have mentioned json, but the other developer doesn’t want to use it.

Thank you in advance!

  • 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-29T06:07:31+00:00Added an answer on May 29, 2026 at 6:07 am

    I know you said the other developer doesn’t want to use JSON but that’s exactly what you’re looking for. Is there a particular reason (s)he’s opposed to using it?

    <?php
        $data = array();
        $results = mysql_query('...');
        while($result = mysql_fetch_assoc($results)) {
            $data[] = $result;
        }
    ?>
    <script language="javascript1.2">
        var arr = <?php echo json_encode($data); ?>;
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an object which I first want to rotate (about its own center)
First I want to describe my situation briefly. I have two classes, one MainClass
I have a problem but first i want to know if im working on
first question here, so hopefully you'll all go gently on me! I've been reading
Ok guys, as promised, here is the real deal, first the sample html: <li
First I want to clearify that I mean by reverse engineering something like decompiling
First I want to apologize for such a silly question but I'm quite new
At first I want to say: I couldn't find a support forum for this
I am trying to do this with MVC 3 EF Model first I want
Hello everyone my problem is very simple. Using entity framework code first I want

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.