I have the following JSON object
[
{
"var1": "ID001",
"var2": "ROY",
"var3": "16"
},
{
"var1": "ID002",
"var2": "MARK",
"var3": "15"
},
{
"var1": "ID003",
"var2": "PETER",
"var3": "15"
}
]
I want to loop through the JSON and pass a value to following MySQL query
$select_data=mysqli_query($connsow, "select * from salary where col1 = '$var1' and col2 = '$var2'");
Below is my code, I used a foreach loop but it always selects the first value in the JSON object. I can't loop through entire JSON and pass the value to query
foreach($rows as $item) {
$cust_ord_no = $item['var1'];
$cont_n = $item['var2'];
$select_data=mysqli_query($connsow, "select * from test where col1 = '$var1' and col2 = '$var2'");
}