5bbcf0ad by Yokihito Oki

csvエクスポート処理修正

1 parent e157d5f2
...@@ -9,34 +9,34 @@ $total_count = 0; ...@@ -9,34 +9,34 @@ $total_count = 0;
9 $db = new mysqli("127.0.0.1","root","KanoyaMbc1124","ad1216tnc7_kanoya","3306"); 9 $db = new mysqli("127.0.0.1","root","KanoyaMbc1124","ad1216tnc7_kanoya","3306");
10 $db->set_charset('utf8'); 10 $db->set_charset('utf8');
11 11
12 $sql = 'SELECT * FROM d_feedback WHERE id > 9 ORDER BY id DESC'; 12 $limit = $_POST['csv_export'] ? NULL : 100;
13 $limit_query = $limit ? ' LIMIT '.$limit : '';
14
15 $sql = 'SELECT * FROM d_feedback WHERE id > 9 ORDER BY id DESC'.$limit_query;
13 $row = $db->query($sql); 16 $row = $db->query($sql);
14 //mysqli_query($db, $sql); 17 //mysqli_query($db, $sql);
15 while( $data = $row->fetch_object()){ 18 while( $data = $row->fetch_object()){
16 $q1_ans = $data->q1; 19 $q1_ans = $data->q1;
17 $q2_ans = $data->q2; 20 $q2_ans = $data->q2;
18 $page_id = $data-> page_id; 21 $page_id = $data->page_id;
19 22 $html_hyo .= '<tr><td>';
20 if($total_count < 100){
21
22 $html_hyo .= '<tr><td>';
23
24 if($page_id){
25 $sql_p = 'SELECT * FROM v4vfh_menu WHERE id = '.$page_id.' LIMIT 1';
26 $row_p = $db->query($sql_p);
27 $data_p = $row_p->fetch_object();
28 $html_hyo .= $data_p->title;
29 }
30 23
31 $html_hyo .= '</td><td>'.$q1_ask[$q1_ans].'</td><td>'.$q2_ask[$q2_ans].'</td><td>'.$data->input_date.'</td>'; 24 if($page_id){
32 $total_count ++; 25 $sql_p = 'SELECT * FROM v4vfh_menu WHERE id = '.$page_id.' LIMIT 1';
33 if($q1_ans == 1) { $q1_count_g++; }elseif($q1_ans == 2) { $q1_count_b++; } 26 $row_p = $db->query($sql_p);
34 if($q2_ans == 1) { $q2_count_g++; }elseif($q2_ans == 2) { $q2_count_b++; } 27 $data_p = $row_p->fetch_object();
35 28 $html_hyo .= $data_p->title;
36 $html_hyo .= '</tr>';
37 } 29 }
30
31 $html_hyo .= '</td><td>'.$q1_ask[$q1_ans].'</td><td>'.$q2_ask[$q2_ans].'</td><td>'.$data->input_date.'</td>';
32 $total_count ++;
33 if($q1_ans == 1) { $q1_count_g++; }elseif($q1_ans == 2) { $q1_count_b++; }
34 if($q2_ans == 1) { $q2_count_g++; }elseif($q2_ans == 2) { $q2_count_b++; }
35
36 $html_hyo .= '</tr>';
37
38 //CSV書出用 38 //CSV書出用
39 $csv_page[] = $data_p->title; 39 $csv_page[] = $page_id ? $data_p->title : '';
40 $csv_q1[] = $q1_ask[$q1_ans]; 40 $csv_q1[] = $q1_ask[$q1_ans];
41 $csv_q2[] = $q2_ask[$q2_ans]; 41 $csv_q2[] = $q2_ask[$q2_ans];
42 $csv_input[] = $data->input_date; 42 $csv_input[] = $data->input_date;
...@@ -54,7 +54,7 @@ if($_POST['csv_export']) { ...@@ -54,7 +54,7 @@ if($_POST['csv_export']) {
54 54
55 $csv_c = 0; 55 $csv_c = 0;
56 $csv_array = []; 56 $csv_array = [];
57 while($csv_page[$csv_c]){ 57 while(isset($csv_page[$csv_c])){
58 $csv_array[$csv_c][] = mb_convert_encoding($csv_page[$csv_c], 'SJIS-win', 'UTF-8'); 58 $csv_array[$csv_c][] = mb_convert_encoding($csv_page[$csv_c], 'SJIS-win', 'UTF-8');
59 $csv_array[$csv_c][] = mb_convert_encoding($csv_q1[$csv_c], 'SJIS-win', 'UTF-8'); 59 $csv_array[$csv_c][] = mb_convert_encoding($csv_q1[$csv_c], 'SJIS-win', 'UTF-8');
60 $csv_array[$csv_c][] = mb_convert_encoding($csv_q2[$csv_c], 'SJIS-win', 'UTF-8'); 60 $csv_array[$csv_c][] = mb_convert_encoding($csv_q2[$csv_c], 'SJIS-win', 'UTF-8');
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!