php 테이블 변경해서 데이터 가져오기 (왕초보) 채택완료
<?
set_time_limit(240);
ini_set('memory_limit','512M');
include_once "./_common.php";
include_once "{$g4[lms_path]}/head.sub.php";
$sql = "select a.*, d.wr_1 as d_wr_1,d.wr_15 as d_wr_15, e.wr_1 as e_wr_1, e.wr_2 as e_wr_2
from {$g4['lms_prefix']}D0777 a
left join
{$g4['lms_prefix']}D04 d
on
a.wr_2 = d.wr_id
left join
{$g4['lms_prefix']}D01 e
on
d.wr_3 = e.wr_id
where
a.wr_2='{$d_id}'
and a.wr_19='{$wr_19}'
and a.wr_20='{$wr_20}'"; // 2018.10.30 오지우 성적표양식변경 및 학생이 확인시 변경된 성적표대로 나오도록 수정
$is = sql_query($sql);
?>
$index = 0;
while($row = sql_fetch_array($is)){
$index++;
$lis_score = "";
$rea_score = "";
$lis_comment = "";
$rea_comment = "";
$one_p = "";
$part1_p = "";
$part2_p = "";
$part3_p = "";
$part4_p = "";
$part5_p = "";
$part6_p = "";
$part7_p = "";
$lis_p = "";
$rea_p = "";
$lis_score = $row['wr_25']; //$row['wr_11']+$row['wr_12']+$row['wr_13']+$row['wr_14'];
$rea_score = $row['wr_26']; //$row['wr_15']+$row['wr_16']+$row['wr_17'];
$today = date("Y-m-d");
$sub_sql = "
SELECT
a.*, b.wr_15 as b_wr_15
FROM
lms_D0777 a
left join lms_D04 b
on a.wr_2 = b.wr_id
WHERE
a.wr_19 = '".$row['wr_19']."' AND
a.wr_2 != '{$d_id}' and
b.wr_12 < '{$today}' and
b.wr_14 < '{$today}'
ORDER BY
a.wr_datetime DESC
LIMIT 0 , 2
";
$sub_is = sql_query($sub_sql);
$sub_as = sql_fetch($sub_sql);
$sub_index = 0;
$one_lis_score = 0;
$one_rea_score = 0;
$one_total_score = 0;
$one_date = null;
$two_lis_score = 0;
$two_rea_score = 0;
$two_total_score = 0;
$two_date = null;
if(!$sub_as) {
$one_lis_score = $one_rea_score = $one_total_score = "-";
$one_date = "이전 시험내역이<br> 없습니다";
$two_lis_score = $two_rea_score = $two_total_score = "-";
$two_date = "이전 시험내역이<br> 없습니다";
}
while($sub_row = sql_fetch_array($sub_is)){
$sub_index++;
if($sub_index == 1){
$one_lis_score = $sub_row['wr_25']; //$sub_row['wr_11']+$sub_row['wr_12']+$sub_row['wr_13']+$sub_row['wr_14'];
$one_rea_score = $sub_row['wr_26']; //$sub_row['wr_15']+$sub_row['wr_16']+$sub_row['wr_17'];
$one_total_score = $sub_row["wr_18"];
if($sub_row['wr_3'] == '2') $one_date = date("Y/m/d", strtotime($sub_row['b_wr_15']));
else $one_date = date("Y/m/d", strtotime($sub_row['wr_datetime']));
}else if($sub_index == 2){
$two_lis_score = $sub_row['wr_25'];//$sub_row['wr_11']+$sub_row['wr_12']+$sub_row['wr_13']+$sub_row['wr_14'];
$two_rea_score = $sub_row['wr_26'];//$sub_row['wr_15']+$sub_row['wr_16']+$sub_row['wr_17'];
$two_total_score = $sub_row["wr_18"];
if($sub_row['wr_3'] == '2') $two_date = date("Y/m/d", strtotime($sub_row['b_wr_15']));
else $two_date = date("Y/m/d", strtotime($sub_row['wr_datetime']));
}
}
if($row['e_wr_1'] == "1"){
$one_p = "5";
$part1_p = ($row['wr_11']/(6*$one_p))*100;
$part2_p = ($row['wr_12']/(25*$one_p))*100;
$part3_p = ($row['wr_13']/(39*$one_p))*100;
$part4_p = ($row['wr_14']/(30*$one_p))*100;
$part5_p = ($row['wr_15']/(30*$one_p))*100;
$part6_p = ($row['wr_16']/(16*$one_p))*100;
$part7_p = ($row['wr_17']/(54*$one_p))*100;
$lis_p = ($lis_score/495)*100;
$rea_p = ($rea_score/495)*100;
}else if($row['e_wr_1'] == "2"){
$one_p = "10";
$part1_p = ($row['wr_11']/(3*$one_p))*100;
$part2_p = ($row['wr_12']/(14*$one_p))*100;
$part3_p = ($row['wr_13']/(18*$one_p))*100;
$part4_p = ($row['wr_14']/(15*$one_p))*100;
$part5_p = ($row['wr_15']/(15*$one_p))*100;
$part6_p = ($row['wr_16']/(8*$one_p))*100;
$part7_p = ($row['wr_17']/(27*$one_p))*100;
$lis_p = ($lis_score/495)*100;
$rea_p = ($rea_score/495)*100;
}
if((0<$lis_score && $lis_score<=150) || !$lis_score){
$lis_cha = "wr_19";
$lis_weak = "wr_20";
$lis_comment = "wr_21";
}else if(150<$lis_score && $lis_score<=270){
$lis_cha = "wr_16";
$lis_weak = "wr_17";
$lis_comment = "wr_18";
}else if(270<$lis_score && $lis_score<=322){
$lis_cha = "wr_13";
$lis_weak = "wr_14";
$lis_comment = "wr_15";
}else if(322<$lis_score && $lis_score<=370){
$lis_cha = "wr_10";
$lis_weak = "wr_11";
$lis_comment = "wr_12";
}else if(370<$lis_score && $lis_score<=415){
$lis_cha = "wr_7";
$lis_weak = "wr_8";
$lis_comment = "wr_9";
}else if(415<$lis_score && $lis_score<=455){
$lis_cha = "wr_4";
$lis_weak = "wr_5";
$lis_comment = "wr_6";
}else if(455<$lis_score && $lis_score<=500){
$lis_cha = "wr_1";
$lis_weak = "wr_2";
$lis_comment = "wr_3";
}
if((0<$rea_score && $rea_score<=150) || !$rea_score){
$rea_cha = "wr_40";
$rea_weak = "wr_41";
$rea_comment = "wr_42";
}else if(150<$rea_score && $rea_score<=270){
$rea_cha = "wr_37";
$rea_weak = "wr_38";
$rea_comment = "wr_39";
}else if(270<$rea_score && $rea_score<=322){
$rea_cha = "wr_34";
$rea_weak = "wr_35";
$rea_comment = "wr_36";
}else if(322<$rea_score && $rea_score<=370){
$rea_cha = "wr_31";
$rea_weak = "wr_32";
$rea_comment = "wr_33";
}else if(370<$rea_score && $rea_score<=415){
$rea_cha = "wr_28";
$rea_weak = "wr_29";
$rea_comment = "wr_30";
}else if(415<$rea_score && $rea_score<=455){
$rea_cha = "wr_25";
$rea_weak = "wr_26";
$rea_comment = "wr_27";
}else if(455<$rea_score && $rea_score<=500){
$rea_cha = "wr_22";
$rea_weak = "wr_23";
$rea_comment = "wr_24";
}
$sql = "select * from {$g4['lms_prefix']}D06";
$comment = sql_fetch($sql);
$crm_info = get_crm2($member[mb_id]);
$imagPath='20230411_110638431.jpg';
$image = imagecreatefromjpeg($imagePath);
$text = '하이헬로우';
imagettftext($image, 20, 0, 50, 50, $textColor, 'arial.ttf', $text);
header('Content-Type: image/jpeg');
imagejpeg($image);
?>
ㅇ이런 코드에서 lms_D07 을 D0777 로 바꿨는데, 왜 D0777에있는 정보가 조회가 되지않는건가요 ㅠㅠ
DB D07과 D0777 똑같이 만들었고 데이터도 들어가있습니다.
이걸로 알려주실수있나요
답변 2개
오류 내용을 먼저 확인 해봐야 할것 같습니다.
먼저 D0777에 테이블 정보가 맞는지 확인해보시구 맞다면 오류 내용을 보여주세요.
답변에 대한 댓글 6개
페이지 상단에 디렉티브 설정하여 확인해보세요
error_reporting(E_ALL);
ini_set('display_errors', 1);
또한
PHP 에러 로그와 데이터베이스 로그를 확인하여 주시구요
만약 오류 내용을 몰르겠다면 스크립트 내부에 추가하여 확인해보시는 방법도 있습니다.
error_log("무엇이문제일까요?", 3, "/파일경로이름/error.log");
if(!$exam_check_list){
alert("성적이 등록된 시험이 없습니다.");
exit();
}
?>
<link rel="stylesheet" href="<?=$g4['lms_plug_path']?>/offline_exam_info/style.css">
<div class="exam_info_wrap">
<b>성명:<?=$wr_20?> / 핸드폰번호:<?=$wr_19?> </b>
<table class="lecture_tb" cellpadding="0" cellspacing="0">
<thead>
<colgroup>
</colgroup>
</thead>
<tbody>
<tr>
<th>시험명</th>
<th>응시기간</th>
<th>열람</th>
</tr>
<?
for($i=0; $i < count($exam_check_list);$i++){
$exam_info = get_exam_list($exam_check_list[$i]['wr_2'],2);
if($exam_info=="") continue;
?>
<tr>
<td ><?=$exam_info['wr_subject']?></td>
<td><?=$exam_info['wr_15']?> ~ <?=$exam_info['wr_16']?></td>
<? $wr_20 = iconv_substr($wr_20,0,4,"utf-8"); ?>
<td><a class="btn7" href="./info_exam333.php?wr_20=<?=$wr_20?>&wr_19=<?=$wr_19?>&d_id=<?=$exam_check_list[$i]['wr_2']?>" target="_self">성적표조회</a></td>
</tr>
<?}?>
</tbody>
</table>
</div>
<?
include_once("{$g4[lms_class_path]}/tail.sub.php");
?>
혹시 여기 페이지랑은 관련 없는건가요 ?
그렇다면....
lms_D07를 lms_D0777로 변경하셨다고 하셨는데요.
그렇다면,
코드에서 lms_D0777로 변경한 경우 모든 관련 코드에서 해당 변경 사항을 반영해야 하는데...확인이 필요할것같습니다. 즉 코드에서도 이에 맞게 변경해야 한다는 거겠죠.
또한 SQL 쿼리문에서 테이블 이름을 변경해보세요.
$sql = "SELECT * FROM {$g4['lms_prefix']}D0777";
이런식으로 하여도 문제가 해결되지 않는 경우?
데이터베이스 연결 및 쿼리 실행에 관련된 코드 부분을 확인하여 해보시고 그래도 문제가 있다면?
에러 메시지나 디버깅 도구를 사용하여 추가 정보를 확인 하시고 하시면 될 것 같습니다.
찬찬히 하나씩 느림의 미학으로 응원 할께요 화이팅!~
댓글을 작성하려면 로그인이 필요합니다.
$is = sql_query($sql, true);
Exit;
// 하셔서 SQL 에러가 있는지 확인해 보세요
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인