Guest User

Untitled

a guest
Dec 19th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. <?php
  2. //Define your host here.
  3. $servername = "sql111.epizy.com";
  4. //Define your database username here.
  5. $username = "epiz_21267382";
  6. //Define your database password here.
  7. $password = "*******";
  8. //Define your database name here.
  9. $dbname = "epiz_21267382_alidb";
  10. ?>
  11.  
  12. <?php
  13.  
  14. include 'dbconfig.php';
  15.  
  16. $con = mysqli_connect($servername,$username,$password,$dbname);
  17. //creating a query
  18. $stmt = $con->prepare("SELECT POWER , ONE_THRUST_BEARING_METAL_TEMP
  19.  
  20. FROM turbine_table ORDER BY id DESC LIMIT 1;");
  21.  
  22. //executing the query
  23. $stmt->execute();
  24.  
  25. //binding results to the query
  26. $stmt->bind_result($t1,$t2);
  27.  
  28. $boiler = array();
  29.  
  30. //traversing through all the result
  31. while($stmt->fetch()){
  32. $temp = array();
  33.  
  34. $temp['t1'] = $t1;
  35. $temp['t2'] = $t2;
  36.  
  37. array_push($boiler, $temp);
  38. }
  39.  
  40. //displaying the result in json format
  41. echo json_encode($boiler);
  42. ?>
  43.  
  44. StringRequest stringRequest1=new StringRequest(Request.Method.GET,"http://alibhm.epizy.com/fetch_turbine2.php",
  45. new Response.Listener<String>() {
  46. @Override
  47. public void onResponse(String response) {
  48. try {
  49. JSONArray array=new JSONArray(response);
  50. for (int i=0; i < array.length(); i++) {
  51. JSONObject product=array.getJSONObject(i);
  52.  
  53. String b1=product.getString("t1");
  54. String b2=product.getString("t2");
  55.  
  56. final TextView a1=findViewById(R.id.pf1);
  57. final TextView a2=findViewById(R.id.pf2);
  58.  
  59. a1.setText(b1);
  60. a2.setText(b2);
  61.  
  62. }
  63. } catch (JSONException e) {
  64. e.printStackTrace();
  65. }
  66. }
  67. },
  68. new Response.ErrorListener() {
  69. @Override
  70. public void onErrorResponse(VolleyError error) {
  71. }
  72. });
  73. Volley.newRequestQueue(this).add(stringRequest1);
Add Comment
Please, Sign In to add comment