1.{"q1":"a1","q2":"a4","q3":"a4","q4":"a1","q5":"a2","q6":"a2","q7":"a2","q9":"a3","q10":"a2","q11":"a2","q12":"a2","q13":"a2","q14":"a3","q15":""}
2.{"q8":"a3","q10":"a1","q11":"a1","q12":"a1","q13":"a1","q15":""}
if($result->num_rows > 0){
$data = array();
while ($row = $result->fetch_assoc()){
$data[] = json_decode($row['data'], true);
}
}
$i = 0;
foreach ($data as $key => $value) {
if ($data[$key]['q1'] == 'a1') {
$i++;
}
}
echo $i;
$data = array();
if($result->num_rows > 0){
while ($row = $result->fetch_assoc()){
$data[] = json_decode($row['data'], true);
}
}
function jsonCount($question, $answer){
global $data;
$i = 0;
foreach ($data as $key => $value) {
if ($data[$key][$question] == $answer) {
$i++;
}
}
return $i;
}
echo jsonCount('q1', 'a1');
echo '<br>';
echo jsonCount('q1', 'a2');