title: getting data from postgres to php to html (with ajax)
body: <p>I am using ajax to call a php script which gets data from my postgres DB.
  In php, my code is:</p>
  
  <pre><code>$sql = "select * from processWebRequest($1)";
  $res = pg_prepare($dbconn, "interaction_insert_query", $sql);
  $res = pg_execute($dbconn, "interaction_insert_query", array($req));
  $myarray = array();
  while ($row = pg_fetch_assoc( $res )/*pg_fetch_row($contests)*/) {
    $myarray[] = $row;
  }
  header('Content-Type: application/json');
  echo json_encode($myarray);// 
  </code></pre>
  
  <p>The problem is that back in ajax</p>
  
  <pre><code>$.ajax({
      url: "../php/recordInteraction.php",
      type: 'GET',
      data : pObject,
      dataType: 'json',
      success: function(response,textStatus,jqXHR){
  </code></pre>
  
  <p>The response variable seems to hold more and more data.  I know each query returns at most two rows, but when I load the file in the debugger the response variable is an array with 25 rows.</p>
  
  <p>Seems like I need to flush something, I just have no idea what.</p>
  
  <p>Can someone help?  Thanks.</p>