0

I am trying to get this array as a result of mysql result.

var availableTags = [
      "ActionScript",
      "AppleScript",
      "Asp",
      "BASIC",
      "C",
      "C++",
      "Clojure",
      "COBOL",
      "ColdFusion",
      "Erlang",
      "Fortran",
      "Groovy",
      "Haskell",
      "Java",
      "JavaScript",
      "Lisp",
      "Perl",
      "PHP",
      "Python",
      "Ruby",
      "Scala",
      "Scheme"
    ];

Is it as simple as:

var availableTags [] = <php echo $result['availabletags']; ?> ;

Or should I do something else?

3
  • 1
    Your question is missing some information Commented Jul 19, 2017 at 10:39
  • It depends upon what your query returns. If it is giving array of objects then you have to change your code. Commented Jul 19, 2017 at 10:41
  • What format is $result['availabletags'] in? Assuming you can create a PHP array from it, then you can do: var availableTags = <php echo json_encode($result['availabletags']); ?>; Commented Jul 19, 2017 at 10:43

1 Answer 1

1

You can get your result by run of following query :

while( $row = mysql_fetch_assoc( $result)){
    $new_array[] = $row; // Inside while loop
}

Let me know if you face any issue.

Sign up to request clarification or add additional context in comments.

2 Comments

I am trying to make this code work with mysql result as autocomplete options. jqueryui.com/autocomplete
What is the easiest way?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.