예약프로그램관련 문의드립니다ㅜㅜ > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

예약프로그램관련 문의드립니다ㅜㅜ 정보

예약프로그램관련 문의드립니다ㅜㅜ

본문

g4_write_online = 예약정보들이 저장된 테이블
$datepass = 선택한날짜

$sql = " select * from g4_write_online where reserv_date = '$datepass' ";
이런식으로 검색하면 해당날짜에 예약한 리스트들이 나오는데요.

여기서 출력된 데이터 중에 wr_1(객실명)값이 있으면 예약불가능 없으면 가능이라고 표시되게 하고싶은데요. 3일째 붙잡고있지만 혼자서는 해결이안되 문의드립니다.ㅠㅜ
아시는 분들은 좀 도와주세요... 설명하기 어려워서 이미지도 올려드립니다.


말도 안 되게 했지만... 제가 작업한 소스는 아래와 같습니다ㅜㅜ

<?
$sql = " select * from g4_write_online where reserv_date = '$datepass' ";
$result = sql_query($sql);
 
 for ($i=0; $roomRow=sql_fetch_array($result); $i++) {
 
              if($roomRow[wr_1] == "a1") {
    $a1 = "<font style='color:red'>(예약불가능)</font>";
}else{
    $a1 = "<font style='color:blue'>(예약가능)</font>";
}

if($roomRow[wr_1] == "a2") {
    $a2= "<font style='color:red'>(예약불가능)</font>";
}else{
    $a2 = "<font style='color:blue'>(예약가능)</font>";
}

.....(중복생략)
}
?>
<table width="720" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="15%" height="30" align="center" class="page_table">객실명</td>
    <td width="18%" height="30" align="center" class="page_table">면적</td>
    <td width="12%" height="30" align="center" class="page_table">인원</td>
    <td width="20%" height="30" align="center" class="page_table">요금</td>
    <td width="20%" height="30" align="center" class="page_table">성수기요금<br />
    (7월 10일 ~ 8월 20일)</td>
    <td width="15%" height="30" align="center" class="page_table_r">예약상태</td>
  </tr>
  <tr>
    <td height="30" align="center" class="page_table2">A구역 1사이트</td>
    <td height="30" align="center" class="page_table2">8.5~9m * 8~8.5m</td>
    <td height="30" align="center" class="page_table2">1박 4인기준</td>
    <td height="30" align="center" class="page_table2">30,000</td>
    <td height="30" align="center" class="page_table2">35,000</td>
    <td height="30" align="center" class="page_table2_r">
    <?= $a1 ?>
    </td>
  </tr>
  <tr>
    <td height="30" align="center" class="page_table2">A구역 2사이트</td>
    <td height="30" align="center" class="page_table2">8.5~9m * 8~8.5m</td>
    <td height="30" align="center" class="page_table2">1박 4인기준</td>
    <td height="30" align="center" class="page_table2">30,000</td>
    <td height="30" align="center" class="page_table2">35,000</td>
    <td height="30" align="center" class="page_table2_r">
    <?= $a2 ?>
    </td>
  </tr>
  . . . 중간생략 (캠핑장이라서 구역이 40이 넘게 나눠져있습니다..)
 </table>

댓글 전체

디비 설계상 ..  테이블을 하나 더 만들어야 되지 않을까 생각 합니다..
wr_id =1 일때.. 방정보가 들어있는.. 테이블 하나 생성 하구요 join 하는것이 어떨런지.??
40여개의 구역을 하나씩 코딩해서 가능, 불가능을 판별하고 출력도 하나씩 코딩해서 한다는 것은
도저히 용납될 수 없는 방법입니다
online테이블에 40여개의 구역을 등록해두고 예약되면 wr_1에 a1, a2 등의 값을 기록하는 것인가요?
어떤 방식으로 하는지를 알아야 간단한 방법이 나올텐데...
어쨌던 위 코드대로 하자면 for문은 아래처럼 만드세요

 for ($i=0; $roomRow=sql_fetch_array($result); $i++) {
  if($roomRow[wr_1])  $pos[$roomRow[wr_1]] = "<font style='color:red'>(예약불가능)</font>";
 }

출력부분은 아래처럼
(프로그래머가 아니어도 이걸 40여개를 반복해서 코딩한다는 것은 정말 거시기합니다)
<tr>
    <td height="30" align="center" class="page_table2">A구역 1사이트</td>
    <td height="30" align="center" class="page_table2">8.5~9m * 8~8.5m</td>
    <td height="30" align="center" class="page_table2">1박 4인기준</td>
    <td height="30" align="center" class="page_table2">30,000</td>
    <td height="30" align="center" class="page_table2">35,000</td>
    <td height="30" align="center" class="page_table2_r">
<?=$pos[a1]?$pos[a1] : "<font style='color:blue'>(예약가능)</font>"; ?>
    </td>
  </tr>
  <tr>
    <td height="30" align="center" class="page_table2">A구역 2사이트</td>
    <td height="30" align="center" class="page_table2">8.5~9m * 8~8.5m</td>
    <td height="30" align="center" class="page_table2">1박 4인기준</td>
    <td height="30" align="center" class="page_table2">30,000</td>
    <td height="30" align="center" class="page_table2">35,000</td>
    <td height="30" align="center" class="page_table2_r">
<?=$pos[a2]?$pos[a2] : "<font style='color:blue'>(예약가능)</font>"; ?>
    </td>
  </tr>
전체 66,558 |RSS
그누4 질문답변 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT