จะตัดส่วนที่แสดงในรายงานที่ไม่จำเป็นได้อย่างไร
ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา จะตัดส่วนที่แสดงในรายงานที่ไม่จำเป็นได้อย่างไร
จะตัดส่วนที่แสดงในรายงานที่ไม่จำเป็นได้อย่างไร
คือผมอยากตัดส่วนที่มันเเสดงออกมาในรายงานที่ผมวงสีแดงไว้ ถ้าไม่อยากให้มันเเสดงต้องแก้โค้ดยังไงครับ
1 |
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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | <?php include ( 'database_connection.php' ); list( $year , $term ) = explode ( "/" , $_POST [ "filter_year" ]); function show_date( $tmp ) { if ( $tmp != "0000-00-00" ) { list( $date , $time ) = explode ( " " , $tmp ); list( $y , $m , $d ) = explode ( "-" , $date ); $y += 543; return $d . "/" . $m . "/" . $y ; } } ?> <html> <head> <title>พิมพ์กราฟ</title> <script src= "js/Chart.bundle.js" ></script> <style type= "text/css" media= "print" > @page { size: landscape; } @media print { .no- print , .no- print * { display: none !important; } } </style> </head> <body> <div class = " box" > <h1 align= "center" >สรุปรายงานนัดหมายอาจารย์ที่ปรึกษา</h1> <h3 align= "center" >ปีการศึกษา : <?php print ( $term )?>/<?php print ( $year +543)?> ประเภท : <?php print $_POST [ "filter_category" ]?></h3> <br /> <?php if ( $_POST [ "print" ]!= "" ) { ?> <style> table { border-collapse: collapse; } table,th,tr,td { border: 1px solid #8b8b8b; } </style> <div class = "table-responsive" > <table border= "1" cellpadding= "5" width= "100%" > <thead> <tr align= "center" > <th>รหัสนักศึกษา</th> <th>ชื่อ</th> <th>วันที่</th> <th>เวลา</th> <th>ประเภท</th> <th>ปีการศึกษา</th> <th>เรื่อง</th> </tr> </thead> <tbody> <?php $column = array ( 'student_number' , 'student_name' , 'app_date' , 'time_id' , 'category_id' , 'app_year' , 'app_message' ); $query = "SELECT * FROM appointment " ; if (isset( $_POST [ 'filter_year' ], $_POST [ 'filter_category' ]) && $_POST [ 'filter_year' ] != '' && $_POST [ 'filter_category' ] != '' ) { list( $year , $term ) = explode ( "/" , $_POST [ 'filter_year' ]); if ( $term == "1" ) { $fyear = " app_date between '" . $year . "-06-15' and '" . $year . "-10-24' " ; } elseif ( $term == "2" ) { $fyear = " app_date between '" . $year . "-11-19' and '" .( $year +1). "-03-17' " ; } else { $fyear = " app_date between '" .( $year +1). "-04-08' and '" .( $year +1). "-06-09' " ; } # $query .= ' WHERE app_year = "' . $_POST [ 'filter_year' ]. '" AND category_id = "' . $_POST [ 'filter_category' ]. '" ' ; $query .= ' WHERE ' . $fyear . ' AND category_id = "' . $_POST [ 'filter_category' ]. '" ' ; } if (isset( $_POST [ 'order' ])) { $query .= 'ORDER BY ' . $column [ $_POST [ 'order' ][ '0' ][ 'column' ]]. ' ' . $_POST [ 'order' ][ '0' ][ 'dir' ]. ' ' ; } else { $query .= 'ORDER BY appstudent_id DESC ' ; } $statement = $connect ->prepare( $query ); $statement ->execute(); $result = $statement ->fetchAll(); $data = array (); foreach ( $result as $row ) { ?> <tr align= "center" > <td><?php print $row [ "student_number" ]?></td> <td><?php print $row [ "student_name" ]?></td> <td><?php print show_date( $row [ 'app_date' ])?></td> <td><?php print $row [ "time_id" ]?></td> <td><?php print $row [ "category_id" ]?></td> <td><?php print $row [ "app_year" ]?></td> <td><?php print $row [ "app_message" ]?></td> </tr> <?php } ?> <tbody> </table> <br /> <br /> <br /> </div> <?php } else { ?> <?php $query = "SELECT month(app_date) as app_month, year(app_date) as app_year, count( appstudent_id) as qty FROM appointment " ; if ( $term == "1" ) { $fyear = " app_date between '" . $year . "-06-15' and '" . $year . "-10-24' " ; } elseif ( $term == "2" ) { $fyear = " app_date between '" . $year . "-11-19' and '" .( $year +1). "-03-17' " ; } else { $fyear = " app_date between '" .( $year +1). "-04-08' and '" .( $year +1). "-06-09' " ; } $query .= ' WHERE ' . $fyear . ' AND category_id = "' . $_POST [ 'filter_category' ]. '" ' ; $query .= ' group by app_month order by app_date' ; $statement = $connect ->prepare( $query ); $statement ->execute(); $result = $statement ->fetchAll(); foreach ( $result as $row ) { $data .= ( $data != "" )? "," : "" ; $data .= $row [ 'qty' ]; $labels .= ( $labels != "" )? "," : "" ; $labels .= '"' . $row [ 'app_month' ]. '/' .( $row [ 'app_year' ]+543). '"' ; } ?> <canvas id= "myChart" style= "width: 75%; height: 50%;" ></canvas> <?php } ?> <button type= "submit" name= "graph" id= "graph" class = "no-print" value= "graph" onclick= "window.print();" >พิมพ์กราฟ</button> </div> </body> </html> <?php if ( $_POST [ "print" ]!= "" ) { ?> <script type= "text/javascript" language= "javascript" > window. print (); </script> <?php } else { ?> <script> var ctx = document.getElementById( "myChart" ).getContext( '2d' ); var myChart = new Chart(ctx, { type: 'bar' , data: { labels: [<?php print $labels ?>], datasets: [{ label: '# จำนวน' , data: [<?php print $data ?>], backgroundColor: [ 'rgba(255, 99, 132, 0.2)' , 'rgba(54, 162, 235, 0.2)' , 'rgba(255, 206, 86, 0.2)' , 'rgba(75, 192, 192, 0.2)' , 'rgba(153, 102, 255, 0.2)' , 'rgba(255, 159, 64, 0.2)' ], borderColor: [ 'rgba(255,99,132,1)' , 'rgba(54, 162, 235, 1)' , 'rgba(255, 206, 86, 1)' , 'rgba(75, 192, 192, 1)' , 'rgba(153, 102, 255, 1)' , 'rgba(255, 159, 64, 1)' ], borderWidth: 1 }] }, options: { scales: { yAxes: [{ ticks: { beginAtZero: true } }] } } }); </script> <?php } ?> |

คำแนะนำ และการใช้งาน
สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก
- ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
ความคิดเห็นที่
1
ถ้าไม่ใช่ส่วนที่มาจากโค้ด ให้ดูที่การตั้งค่าการพิมพ์ จะมี
ให้เลือกว่า ไม่ต้องแสดง
ให้เลือกว่า ไม่ต้องแสดง

ความคิดเห็นที่
2
ทำได้แล้วครับขอบคุณครับพี่นิก พี่ครับถ้าผมจะทำให้หัวข้อส่วนบนกับหัวข้อตารางแสดงทุกครั้งที่ขึ้นหน้าใหม่ต้องแกยังไงครับ

ความคิดเห็นที่
3
ดูเนื้อหานี้เป็นแนวทาง
การแบ่งหน้า การพิมพ์ สำหรับข้อมูลต่อเนื่อง ด้วย css อย่างง่าย http://niik.in/400
https://www.ninenik.com/content.php?arti_id=400 via @ninenik

ขอบคุณทุกการสนับสนุน
![]()