-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathchart_ajax.php
75 lines (69 loc) · 2.99 KB
/
chart_ajax.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
include("db.php");
$survey_sql = mysqli_query($con,"SELECT s.survey_id,
s.survey_name,
s.survey_date,
sq.survey_qid,
sq.question,
sao.survey_aid,
sao.answer,
(SELECT IF(sao.answer = 'other(s)'
OR sao.answer = 'others'
OR sao.answer = 'other',
Coalesce((SELECT
Count(sa.survey_aid)
FROM `survey_answer_other` sa
WHERE
sa.survey_aid = sao.survey_aid
GROUP BY sa.survey_aid), 0),
Coalesce((SELECT Count(sa.survey_aid)
FROM `survey_answer` sa
WHERE sa.survey_aid = sao.survey_aid
GROUP BY sa.survey_aid), 0))) count_answer,
Concat('y:', (SELECT IF(sao.answer = 'other(s)'
OR sao.answer = 'others'
OR sao.answer = 'other', Coalesce(
(SELECT Count(sa.survey_aid)
FROM `survey_answer_other` sa
WHERE
sa.survey_aid = sao.survey_aid
GROUP BY
sa.survey_aid), 0),
Coalesce(
(SELECT Count(sa.survey_aid)
FROM `survey_answer` sa
WHERE
sa.survey_aid = sao.survey_aid
GROUP BY
sa.survey_aid), 0))), ', label:', sao.answer)
diag_data_label
FROM survey_anweroptions sao
LEFT JOIN survey_questionnaire sq
ON sq.survey_qid = sao.survey_qid
LEFT JOIN survey s
ON s.survey_id = sq.survey_id
WHERE s.visibility = 1
ORDER BY sq.survey_qid ");
$z = array();
$zcx = array();
$data_label = array();
$data_value = array();
while ($survey = mysqli_fetch_array($survey_sql))
{
$z[] = $survey['diag_data_label'];
$piece = explode(",", $survey['diag_data_label']);
$part = $piece[0];
$data = explode(":", $part);
$data_label[] = $data[0];
$data_value[] = $data[1];
}
// echo $data_label = json_encode($data_label);
// echo $data_value = json_encode($data_value);
foreach ($z as $key => $value) {
$zcx[] = "{".$value."}";
}
$jencode_title = json_encode($zcx);
$jencode_title = str_replace("\"","",$jencode_title);
$jencode_title = str_replace("}","\"}",$jencode_title);
echo $jencode_title = str_replace("label:","label:\"",$jencode_title);
?>