问题
I am trying to fetch specific columns email from a table using mysql using retrofit using android data. My DB table has the useremail collumn and my ImageList Model Class has the @SerializedName("useremail").
API INTERFACE
public interface ApiInterface2 {
String BASE_URL = "10.0.2.2/uploadmultiple/";
@GET("mylist.php")
Call<List<ImageList>> getImgData(@Query("useremail") String userEmail);}
MAIN CLASS
ApiInterface2 apiInterface = RetrofitInstance.getRetrofitInstance().create(ApiInterface2.class);
Call<List<ImageList>> call = apiInterface.getImgData(userEmail);
call.enqueue(new Callback<List<ImageList>>() {
@Override
////////
});
<?php
include 'dbconfig.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$useremail = $_GET["useremail"];
if(empty($useremail)){echo "UserEmail is null";}
try {
$email = $_REQUEST["useremail"];
// Create connection
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT * FROM `table1` WHERE `useremail` = $email");
///////
?>
I cant seem to get this right. Please help
来源:https://stackoverflow.com/questions/61460461/retrofit-fetch-data-from-mysql-based-on-a-user-inputted-string