Hello, I'm trying to create a web program that'll allow users to select multiple items, pick a date range, and then download a csv with the data that matches one of the selected reasons and falls within the date range. However, no matter what I try, I get "Incorrect syntax near $array" for the SQLSRV_Query.
Any help is appreciated
$array = $_POST['ubreasons'];
// Adding single quotes and comma separated into array
$array = implode(" ',' ", $array);
$array = " ' ".$array." ' ";
$searchQuery = sqlsrv_query($cxn, "SELECT Account, First_Name, Last_Name, SUM(ClaimLineBalance) AS CashValue
FROM v_UnBilledClaims_Report
WHERE UBReason IN ('$array') //Here is where the problem is
GROUP BY Account, First_Name, Last_Name
ORDER BY CashValue DESC");