How do I get javascript to read the output of a php file
<p>First off hello, I am new here.<br>
My problem is that I have a php file pulling info from a database. I will post the code below.
What I need is for my JavaScript to take the output and load it into a list that generates some flash cards.</p>

<p>code sample `$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");</p>

<pre><code>// select database
mysql_select_db($db) or die ("Unable to select database!");
</code></pre>

<p>$query1 = "SELECT * FROM category_tb WHERE cat_name = '$category'";
       $result1 = mysql_query($query1) or die ("Error in query: $query1. " . mysql_error());
        while ($row = mysql_fetch_array($result1))
               { </p>

<pre><code>                $cat_num = $row[1];
        }
</code></pre>

<p>// This establishes a link to MySQL
$query = "SELECT * FROM english_lang, finnish_lang ".
"WHERE english_lang.lang_id = finnish_lang.lang_id AND english_lang.cat_id = $cat_num";
       $rt = mysql_query($query) or die ("Error in query: $query. " . mysql_error());</p>

<p>while($nt=mysql_fetch_array($rt)){
echo "{\"english\": \"$nt[1]\", \"finnish\":  \"$nt[6]\" , \"asked\": states.notAsked},";<br>
}
`</p>

<p>So this basicly gets some data and formats it to be used by the javascript.
if you want to look at the output of this to get a better idea the go here<br>
<a href="http://languagelearner.byethost2.com/vocabulary2.php" rel="nofollow">http://languagelearner.byethost2.com/vocabulary2.php</a><br>
 select 1 of the first 2 categories as they are the only ones with data right<br>
 now.<br>
  the javascript is this:  </p>

<p>code sample `
    

<pre><code>var string1;
var string2;
var number;
var states = {"oneVisible": 0, "bothVisible": 1, "notAsked": 2, "asked": 3}
var state = states.bothVisible;
var numberOfWordsAsked = 0;
var words = {"list": [


    ]
}

function displayWords(){

    if (state == states.bothVisible) {
        if (numberOfWordsAsked &lt; words.list.length) {
            state = states.oneVisible;
            number = Math.floor(Math.random() * words.list.length);
            while (words.list[number].asked == states.asked) {
                number = Math.floor(Math.random() * words.list.length);
            }
            string1 = words.list[number].english;
            string2 = words.list[number].finnish;
            document.getElementById("fin").style.display = 'none';
            document.getElementById("eng").innerHTML = words.list[number].english;
            document.getElementById("fin").innerHTML = words.list[number].finnish;
            document.getElementById("b").value = "Show word";
            document.getElementById("correct").style.display = 'none';
        }
        else {
            document.getElementById("eng").innerHTML = "You know all the words in this category, congratulations!";
            document.getElementById("fin").style.display = 'none';
            document.getElementById("b").style.display = 'none';
            document.getElementById("correct").style.display = 'none';
        }
    }

    else {
        document.getElementById("fin").style.display = 'inline';
        state = states.bothVisible;
        document.getElementById("b").value = "Wrong";
        document.getElementById("correct").style.display = 'inline';
    }
}

function setCorrect(){
    words.list[number].asked = states.asked;
    numberOfWordsAsked += 1;
    displayWords();
}

//--&gt;
&lt;/script&gt;
</code></pre>

<p>`</p>

<p>so the output needs to go in here.<br>
  var words = {"list": [<br>
     ]</p>

<p>Any help would be appreciated. I did not write the javascript, a friend did.<br>
 He used static info in the list. </p>
