i have created custom query which i am sending via POST ajax but problem with it is that how to retrieve that data
i am sending this query = rep_id=4&filter=&filter_val=&rep_id=5&filter=&filter_val=&rep_id=6&filter=&filter_val=&from=p_employee_mst
and here is the function to fetch that query in PHP
$rep="";
foreach ($_POST["rep_id"] as $k => $v) {
$rep[]=$v;
}
print_r($rep);
i am getting following error
Invalid argument supplied for foreach()
if print_r($_POST); i am getting this
Array
(
[rep_id] => 6
[filter] =>
[filter_val] =>
[from] => p_employee_mst
)
In your example rep_id is a simple integer value. When you put more then one parameter to your variable you get the last one. in Your case its rep_id=6.
If you want an array then make an array in your request.
then you get as result:
And then you can iterate over the array. Otherwise you get the following result:
Because the last value / parameter win.