I have an app which loads data from a server and publish that data in the text view but there is a scene
<?php
define('HOST','xxxxxx');
define('USER','xxxxxxx');
define('PASS','xxxxx');
define('DB','xxxxxxx');
//Connecting to Database
$con = mysqli_connect(HOST,USER,PASS,DB) or die('Unable to Connect');
$sql = "select * from Leaderboard where email='test@test.com'";
$res = mysqli_query($con,$sql);
$result = array();
while($row = mysqli_fetch_array($res)){
array_push($result,
array('name'=>$row[1],
'rank'=>$row[2],
'accuracy'=>$row[3]));
}
echo json_encode (array("list"=>$result));
mysqli_close($con);
?>
this is my PHP file which gives JSON like this
{"list":[{"name":"Vipul S","rank":"1","accuracy":"80"}]}
and I am getting these values into my android app very easily using volley library but the thing is I need something to make that email variable dynamic because I am getting user email from users phone so I need to pass a variable to PHP through my android, so is there any chance that I can pass this through my URL which is written in android
my URL is: "http://thehostels.in/judgement_files/myleaderboard.php"
so can I pass the emails from URL that will be taken by PHP file through
$email=$_GET['userEmail'];
finally what I want is to that the JSON should change according to email that changes due to URL, I hope I made sense
You can pass email id in URL as
http://thehostels.in/judgement_files/myleaderboard.php?userEmail=test@test.com
and you can use this parameter in PHP as below
$email = $_GET['userEmail'];
$sql = "select * from Leaderboard where email='$email'";
For security reason you should use proper validation for email id.