Server IP : 119.59.102.212 / Your IP : 3.138.121.183 Web Server : Apache/2 System : Linux narin 2.6.32-042stab142.1 #1 SMP Tue Jan 28 23:44:17 MSK 2020 x86_64 User : yangkam ( 1022) PHP Version : 5.6.40 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/yangkam/domains/yangkam.go.th/public_html/coremain/module/question/ |
Upload File : |
<?php import_request_variables('pG', 'p_'); $sel_q = "select * from cms_question where id_sub = '$p_id_sub'"; $que_q = mysql_query($sel_q); $obj_q = mysql_fetch_assoc($que_q); $qid = $obj_q['id_question']; $navig['question&id_sub='.$p_id_sub] = $obj_q['topic']; $navig['question_show&id_sub='.$p_id_sub.'&question='.$qid] = 'ผลสำรวจ'; $navig['question_detail'] = 'รายละเอียด'; navigator($navig); echo"<br>"; bar_header($obj_q['topic']); // Bar_Header fieldset_top($obj_q['topic']); # question_title $array_title = array(); $sel_title = "select * from cms_question_title where question_id = '$qid' and title_parent = '0' order by title_order"; $que_title = mysql_query($sel_title); while($obj = mysql_fetch_assoc($que_title)){ $array_title[$obj['title_order']]['title'] = $obj; # question_choice $choice = array(); $sel_choice = "select * from cms_question_choice where question_id = '$qid' and title_id = '$obj[title_id]' order by choice_order"; $que_choice = mysql_query($sel_choice); while($_choice = mysql_fetch_assoc($que_choice)){ $choice[$_choice['choice_order']] = $_choice; } $array_title[$obj['title_order']]['choice'] = $choice; } # data_title $sel_data = "select * from cms_question_title where question_id = '$qid' and title_parent > '0' order by title_order"; $que_data = mysql_query($sel_data); while($obj = mysql_fetch_assoc($que_data)){ $array_data[$obj['title_parent']][$obj['title_order']] = $obj; } $num_question = count($array_title); $row_per_page = 1; //กำหนดจำนวนบรรทัดต่อหน้า if (empty($p_startrow)) { //ลองตรวจดูว่าค่าแถวเริ่มต้นที่จะแสดงไม่ได้กำหนดหรือเปล่า ถ้าไม่ได้กำหนด จะกำหนดให้เป็น 0 $startrow = 0; }else{ $startrow = $p_startrow; } $query="select * from cms_question_ansheader where question_id = '$qid' order by header_id desc"; $query_count="select count(header_id) from cms_question_ansheader where question_id = '$qid' order by header_id desc"; $result = mysql_query($query_count); $row = mysql_fetch_array($result); $total_row = $row[0]; //ได้ค่าจำนวนบรรทัดทั้งหมดที่จะต้องแสดง $total_page = intval((($total_row-1)/$row_per_page)+1); //หาค่าจำนวนหน้าทั้งหมดที่ต้องแสดง $current_page = (($startrow)/$row_per_page)+1; //หาว่าหน้าที่แสดงอยู่ปัจจุบันเป็นหน้าที่เท่าไหร่ $array_header = array(); $sel_header = $query." LIMIT $startrow,$row_per_page"; $que_header = mysql_query($sel_header); while($obj_header = mysql_fetch_assoc($que_header)){ $arr = explode('_', $obj_header['user_ip']); $obj_header['ip_answer'] = $arr[0]; $array_header[$obj_header['header_id']] = $obj_header; } #debuga($array_header); $array_answer = array(); $sel_answer = "select * from cms_question_answer where question_id = '$qid'"; $que_answer = mysql_query($sel_answer); while($obj_answer = mysql_fetch_assoc($que_answer)){ $arr = explode('::', $obj_answer['answer']); if(count($arr) > 1){ $obj_answer['answer'] = $arr[0]; $obj_answer['text_other'] = $arr[1]; } $array_answer[$obj_answer['header_id']][$obj_answer['title_id']] = $obj_answer; } if ($total_page>1) { //ตรวจดูว่าถ้าจำนวนหน้าทั้งหมดมีไม่เกิน 1 หน้า ต้องแสดงบรรทัดที่จะให้เลือกหน้า $previous_page = $current_page-1; //หาว่าหน้าก่อนหน้าปัจจุบันคือหน้าอะไร $next_page = $current_page+1; //หาว่าหน้าถัดจากหน้าปัจจุบันคืออะไร if ($previous_page >0) { //ถ้าหน้าก่อนหน้าติดลบหรือเป็นศูนย์แสดงว่าไม่สามารถแสดงหน้าก่อนหน้าได้ $new_startrow = $startrow - $row_per_page ; $left_page_show = '<a href="index.php?mod=question_detail&path=question&id_sub='.$p_id_sub.'&question='.$qid.'&startrow='.$new_startrow.'"><b>ก่อนหน้า</b></a> '; } else { $left_page_show = "<b>ก่อนหน้า</b> "; } if ($next_page > $total_page) { //ถ้าหน้าถัดไป มากกว่าจำนวนหน้าทั้งหมด แสดงว่าไม่สามารถแสดงหน้าถัดไปได้ $right_page_show = " <b>ต่อไป</b>"; } else { $new_startrow = $startrow + $row_per_page; $right_page_show = ' <a href="index.php?mod=question_detail&path=question&id_sub='.$p_id_sub.'&question='.$qid.'&startrow='.$new_startrow.'"><b>ต่อไป</b></a>'; } $middle_page_show = ""; for ($i=1;$i<=$total_page;$i++) { //วนลูปแสดงหน้าทั้งหมด if ($i == $current_page) { //ถ้าหน้าที่พิมพ์เป็นหน้าเดียวกับหน้าปัจจุบัน แสดงให้ไม่สามารถคลิ๊กได้ $middle_page_show .= " <font color='ff0000'><b>[$i]</b></font> "; } else { $new_startrow = (($i-1)*$row_per_page); $middle_page_show .= ' <b><a href="index.php?mod=question_detail&path=question&id_sub='.$p_id_sub.'&question='.$qid.'&startrow='.$new_startrow.'">'. $i .'</a></b> '; } } $page_show = $left_page_show . $middle_page_show . $right_page_show; } else { $page_show = ""; } ?> <font color='0000ff' class='Menu'><?= $page_show ?></font> <br/><br/> <?php if(count($array_header) == 0){ ?> <center><h4>- ยังไม่มีผลสำรวจ -</h4></center> <?php }else{ ?> <?php foreach($array_header as $header_id => $header){ ?> <table width="97%" border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td style="padding-bottom: 10px;" align="right">เมื่อวันที่ <?= $header['datetime'] ?></td><!--[IP : <?//= $header['ip_answer'] ?>] ?>--> </tr> <?php foreach($array_title as $title_order => $title){ $t_id = $title['title']['title_id']; $type = $title['title']['type_id']; $answer = $array_answer[$header_id]; ?> <tr> <td> <table width="100%" border="0" cellpadding="3" cellspacing="0" style="border-collapse: collapse;"> <?php if($type == '1'){ ?> <tr bgcolor="#f0e8d0"> <td colspan="2"><?= $title['title']['title_name'] ?></td> </tr> <?php if(isset($array_data[$t_id])){ foreach($array_data[$t_id] as $data_order => $data){ ?> <tr> <td width="50%"> <?= $data_order ?>) <?= $data['title_name'] ?><?php echo $data['title_validate'] == 1 ? ' <span style="color: #ff0000">*</span>' : '' ?> </td> <td width="50%">: <?= $answer[$data['title_id']]['answer'] ?></td> </tr> <?php }} ?> <?php }else if($type == '2'){ ?> <tr> <td> <table width="100%" border="0" cellpadding="3" cellspacing="0" style="border-collapse: collapse;"> <tr bgcolor="#f0e8d0"> <td><?= $title['title']['title_name'] ?></td> <?php foreach($title['choice'] as $order_choice => $choice){ ?> <td width="10%" align="center"><?= $choice['choice_name'] ?></td> <?php } ?> </tr> <?php if(isset($array_data[$t_id])){ foreach($array_data[$t_id] as $data_order => $data){ ?> <tr> <td style="text-indent: 20px;"><?= $data_order ?>) <?= $data['title_name'] ?></td> <?php foreach($title['choice'] as $order_choice => $choice){ ?> <td align="center"><?= $answer[$data['title_id']]['answer'] == $choice['choice_id'] ? '/' : '' ?></td> <?php } ?> </tr> <?php }} ?> </table> </td> </tr> <?php }else if($type == '3' || $type == '4'){ ?> <tr> <td> <table width="100%" border="0" cellpadding="3" cellspacing="0" style="border-collapse: collapse;"> <tr bgcolor="#f0e8d0"> <td><?= $title['title']['title_name'] ?></td> </tr> <?php if(isset($array_data[$t_id])){ foreach($array_data[$t_id] as $data_order => $data){ if($data['title_id'] == $answer[$t_id]['answer']){ ?> <tr> <td style="text-indent: 20px;"><?= $data['title_name'] ?> <?= isset($answer[$t_id]['text_other']) ? '('.$answer[$t_id]['text_other'].')' : '' ?></td> </tr> <?php }}} ?> </table> </td> </tr> <?php }else if($type == '5'){ ?> <tr bgcolor="#f0e8d0"> <td><?= $title['title']['title_name'] ?></td> </tr> <tr> <td style="text-indent: 20px;"><?= $answer[$t_id]['answer'] ?></td> </tr> <?php }else if($type == '6'){ ?> <tr bgcolor="#f0e8d0"> <td><?= $title['title']['title_name'] ?></td> </tr> <?php if(isset($array_data[$t_id])){ foreach($array_data[$t_id] as $data_order => $data){ ?> <tr> <td style="text-indent: 20px;"><?= $data['title_name'] ?></td> </tr> <?php } } ?> <?php } ?> </table> </td> </tr> <?php } ?> </table> <hr/> <?php } ?> <?php } ?>