title: Using Ajax, to work with a mysql database to download files from server
body: <p>I have created a table in my database called 'coursework'I am trying to create a button that downloads the files from the 'coursework' field inside the 'coursework' table in the database to the users computer. I have created the following php code:
      
  
  <pre><code>include 'connection.php'; //This calls up the database 
  
  $user = $_GET['user'];
  
  $query  = "SELECT coursework FROM coursework where b_code = '".$user."'" ;
  $result = mysqli_query($conn, $query) or die('Invalid query');
  
  $count = mysqli_fetch_array($result);
  echo '{"coursework_number":'.json_encode($count[0]).'}';
  ?&gt;
  </code></pre>
  
  <p>The mysql statement does retrieve the file from the database because I have tested the query in phpMyAdmin. my problem is i am trying to get the file to download via a button using jquery/ajax. Can someone please help?</p>
  
  <p>Thanks!</p>