title: how can i pass back data from php to android using variables
body: <p>I have some data that i passed a httpurlconnection to a php script which gets the variables that have been encoded throught the urlencoder, now i want to get a response back from the script i can do this with an echo but that will not solve my problem i want to save data in different variables just like how it is done using the url encoder for the android part and then send those variables back to the android device. How can i accomplish this please. This is the code for sending the data and receiving response </p>
  
  <pre><code> String data = URLEncoder.encode("studentschool","UTF-8")+"="+URLEncoder.encode(getStudentSchool,"UTF-8")+"&amp;"+
                    URLEncoder.encode("studentdepartment","UTF-8")+"="+URLEncoder.encode(getStudentDepartment,"UTF-8")+"&amp;"+
                    URLEncoder.encode("studentcurrentyear", "UTF-8")+"="+URLEncoder.encode(getStudentCurrentYear, "UTF-8");
  
              bufferedWriter.write(data);
              bufferedWriter.flush();
              bufferedWriter.close();
              outputStream.close();
  
              InputStream inputStream = httpURLConnection.getInputStream();
              BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
              String response = " ";
              String line = "";
              while ((line = reader.readLine()) != null){
                  response+=line;
              }
              reader.close();
              httpURLConnection.disconnect();
              inputStream.close();
              return response;
          } catch (MalformedURLException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
  </code></pre>
  
  <p>And this is my php</p>
  
  <pre><code>require "init.php";
  
  $school = @$_POST["studentschool"];
  $department = @$_POST["studentdepartment"];
  $school_year = @$_POST["studentcurrentyear"];
  
  $query = "SELECT *
                FROM `users`
                WHERE `school` = '$school'
                 AND  `department` = '$department'
                 AND  `schoolyear` = '$school_year'
                  AND `courserep` = '1' LIMIT 1";
  
  $result= mysqli_query($link,$query);
  
  if (mysqli_num_rows($result)&gt; 0){
    $row = mysqli_fetch_assoc($result);
    $monday = $row["Monday"];
    $tuesday = $row["Tuesday"];
    $wednesday = $row["Wednesday"];
    $thursday = $row["Thursday"];
    $friday = $row["Friday"];
  
    echo $monday;
    echo $tuesday;
  }
  </code></pre>