I have a PHP file below
<pre><?php
require dirname(__FILE__).'/../DbConnection/conn.php';
if($conn){
$sqlStr = "SELECT
YEAR(OrderBill.BillingDate) AS year,
SUM(MultiPay.Amount) AS growth_rate
FROM Rst_TblMultiPayModes MultiPay
LEFT OUTER JOIN Rst_TblOrderBills OrderBill
ON MultiPay.OrderBillCode = OrderBill.OrderBillCode
WHERE OrderBill.isBillCleared=1 AND OrderBill.isMerged=0
AND MultiPay.PaymentMode IN(1,2,3,4,6,7)
$_GET['mselectperiod']
GROUP BY
YEAR(OrderBill.BillingDate)";
$sqlResult = mysqli_query($conn,$sqlStr);
$response = array();
while($row = mysqli_fetch_assoc($sqlResult)){
array_push($response,$row);
}
echo json_encode($response);
mysqli_close($conn);
}else{
echo "Host Connection Error";
}
?>
This PHP file works fine when I execute it in my browser (
http://localhost/hotelwiseapp/Reports/salesgrowthratechartyear.php?mselectperiod=AND YEAR(OrderBill.BillingDate)=2019 AND YEAR(OrderBill.BillingDate)=2022)
and resulting as follows
"[{"year":"2019","growth_rate":"908650"},{"year":"2020","growth_rate":"16957700"},{"year":"2021","growth_rate":"27837121"}]"
Now when it comes to Android, I use Retrofit library as follows by creating an interface
<pre>public interface ApiInterface {
@GET("{PHP_QRY_FILE_NAME}")
Call<List<Growth>> getGrowthInfo(@Path(value="PHP_QRY_FILE_NAME",encoded = true) String mPhpQryFileName);
}
Then I call as follows
call = ChartApiClient.getApiClient().create(ApiInterface.class).getGrowthInfo("salesgrowthratechartyear.php);
The Above Also Works Fine But Only when I Remove
$_GET['mselectperiod'] In The PHP File. The Problem Comes When I want To Use
$_GET['mselectperiod'] In That Php File and then modifying My Interface with a
@Query Annotation As Follows
<pre>public interface ApiInterface {
@GET("{PHP_QRY_FILE_NAME}")
Call<List<Growth>> getGrowthInfo(@Path(value="PHP_QRY_FILE_NAME",encoded = true) String mPhpQryFileName, @Query("mselectperiod") String mWhereClause);
}
Then I call as follows
call = ChartApiClient.getApiClient().create(ApiInterface.class).getGrowthInfo("salesgrowthratechartyear.php",SalesGrowthChart.mFinalSelectPeriodQry);
Note That
'SalesGrowthChart.mFinalSelectPeriodQry' is a variable That Receives a Changing String values as below
"AND YEAR(BillingDate)>=2019 AND YEAR(BillingDate)<=2022"
Nothing happens. What am I missing?
What I have tried:
Passing string parameters to a PHP file Using the @Query Annotation