I am trying to display information retrieved from server using php in an android app,I have retrieved the information in a String with json formatting here is the retrieve code and php code. PHP code
<?php
if($_SERVER['REQUEST_METHOD']=='POST')
{
//Getting values
$username = $_POST['username'];
require_once('dbConnect.php');
$sql = "SELECT * FROM `employee` WHERE username='$username'";
$result=mysqli_query($con,$sql);
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
echo json_encode($row);
}
Android Retrieve code
@Override
protected String doInBackground(Void... params) {
// TODO: attempt authentication against a network service.
HashMap<String,String> params1= new HashMap<>();
params1.put(Config.KEY_EMP_UN,mUsername);
RequestHandler rh = new RequestHandler();
String res = rh.sendPostRequest(Config.URl_RET, params1);
return res;
// TODO: register the new account here.
}
@Override
protected void onPostExecute(final String success) {
Toast.makeText(Main2Activity.this,success,Toast.LENGTH_LONG).show();
final TextView Textview1 = (TextView)findViewById(R.id.textView);
Textview1.setText(success);
}
This retrieves info in format shown in below image
What is want to do is extract Name,Designation,Salary,Password and display them in separate TextView.How can I do that?