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에 테이블 정보가 맞는지 확인해보시구 맞다면 오류 내용을 보여주세요.
$is = sql_query($sql, true);
Exit;
// 하셔서 SQL 에러가 있는지 확인해 보세요