sql 쿼리결과값을 다른sql 조건에 넣기 배열?
본문
$sql 에서 직원명 조회하고, 두번째 for 안에 $sql_office_time 에서 해당직원의 wr_7 값을 가져오려고 합니다.
https://sir.kr/qa/437284?&vpage=1#c_437330
이런 도표형식으로요,
근데, 맨처음 한명꺼만 노출되고 있습니다. 그래서 처음 $sql 값으로 두번재 쿼리 조건에 넣고 싶은데,
어떻게 수정해야 될까요?
고수님들 도와주세요~
<table>
<tr>
<td align=center>순서</td>
<td align=center>이름</td>
<?php for($i>0; $i <= $month_day; $i++){ ?> <td align=center><?php echo $i ?></td> <?php } ?>
<td align=center>합계</td>
</tr>
<?
$sql_common = " from {$g5['member_table']} ";
$sql_search = " where (1) ";
$sql_search .= " and mb_id != '{$config['cf_admin']}' "; // 최고관리자 제외
$sql_order = " order by mb_name";
$sql = " select mb_name {$sql_common} {$sql_search} {$sql_order}";
//echo $sql;
$result = sql_query($sql);
for ($i=0; $rows=sql_fetch_array($result); $i++) {
$y++;
$mb_name = $rows['mb_name'];
?>
<tr>
<td align=center><strong><?php echo $y ?></strong></td>
<td align=center><strong ><?php echo $mb_name ?></strong></td>
<?php
for($a>0; $a <= $month_day; $a++){
$b++;
$sql_office_time = "select * from $write_table where wr_name in ($sql) and wr_datetime LIKE '%".$start_year.'-'.$start_month.'-'.insert_0($b)."%'";
echo $sql_office_time;
$result_office_time = sql_query($sql_office_time);
$row_office_time=sql_fetch_array($result_office_time);
?>
<td align=center><?php echo substr($row_office_time['wr_datetime'],2,8);; ?><?php echo $row_office_time['wr_7']; ?></td>
<?php
}
?>
</tr>
<?php
}
?>
</table>
답변 1
$sql_office_time = "select * from $write_table where wr_name in ($sql) and wr_datetime LIKE '%".$start_year.'-'.$start_month.'-'.insert_0($b)."%'";
echo $sql_office_time;
이 변수가 문제인 거 같군요.
답변을 작성하시기 전에 로그인 해주세요.