title: PHP, JavaScript and MySQL: updating and passing of variables
body: <p>I am trying to increment a number and update the database and then display the number without refreshing the page. I am just wondering, is there a way to read/update MySQL using JavaScript?</p>
  
  <p>I tried searching around, and it seems you have to call another program that changes the values for you. Right now I have</p>
  
  <pre><code>&lt;?php
  require ("connect.php");
  
  echo "connected!&lt;br&gt;";
  
  $extract = mysql_query("SELECT * FROM articles")or die ("Not working");
  
  //$numrows = mysql_num_row($extract);
  
  while ($row = mysql_fetch_assoc($extract)) {
  
      $id = $row['id'];
      $article = $row['article'];
      $thumbsup= $row['thumbs_up'];
      $thumbsdown = $row['thumbs_down'];
      $date = $row['date_time'];
      $username = $row['username'];
      mysql_query("UPDATE articles SET thumbsup = 1");
  }
  ?&gt;
  </code></pre>
  
  <p>So I am wondering, once this page updates the database, how do you get the updated value into the JavaScript function? Right now I am just reading it from a file</p>
  
  <pre><code>xmlhttp.open("GET", "http://localhost/ajax/folder5/includes/a.txt", true);
  </code></pre>
  
  <p>Thanks a lot for your help!</p>