title: how to pass sql query result to a javascript function?
body: <p>hello
  I wanted to know whats the best way to send sql results to a javascript function.
  I have two dropdown lists and i want to populate the second one according to the first one.
  both dropdown lists arre populated from a mysql database.
  fillcourses is the javascript function but i dont know how to pass the result array to it.</p>
  
  <pre><code>$db = new Db();
      $db-&gt;query('SELECT idDepartment,name FROM department');
      &lt;select name="department" onchange=" fill_courses (
          SELECT courseNumber,courseId FROM courses 
          WHERE Department_idDepartment = document.addCourse.department.selectedIndex.value); "&gt;';
          while ($row=$db-&gt;nextRow())
          {
              echo'&lt;option value="' . $row['idDepartment'] . '"&gt;' . $row['name'] . '&lt;/option&gt;';
          }
          echo'&lt;/select&gt;
          &lt;select name="courses"&gt;
          &lt;/select&gt;
  </code></pre>