댓글 목록

상담 게시판 만들기 #3

페이지 정보

작성자 운영자 작성일 18-01-23 11:29 조회 1,716 댓글 0

동영상 강좌는 유튜브 채널 '웹학교'를 이용하시기 바랍니다.

상담 게시판 목록처리를 해보도록 하겠습니다.


해당 파일 : list.skin.php


일반 사용자 목록화면

43281f6cdad1eec44c1d83bb9e9dabdd_1516674005_1942.png


관리자가 보는 목록화면
43281f6cdad1eec44c1d83bb9e9dabdd_1516674005_2368.png
 

사용자가 상담게시판에 쓴 내용을 목록으로 보는 화면구현입니다.


특이한 것은 개인정보 보호 처리를 하여 일반인은 목록에서 입력정보중 성명과 전화번호를 제대로 볼 수 없다는 것입니다.

대신 관리자로 로그인하였을 때는 성명과 전화번호 정보를 완전히 볼 수 있도록 처리합니다.


상담게시판 목록에서 보여주는 정보는 아래와 같습니다.

<th scope="col">번호</th>
<th scope="col">상담구분</th>
<th scope="col">성명</th>
<th scope="col">연락처</th>
<th scope="col">상태</th>

개인정보 보호를 위해 사용하는 php함수는 3개입니다.

  • substr() : 문자열 길이를 임의로 자를 때
  • strlen() : 문자열 길이를 구할 때
  • str_pad() : 특정 부분을 원하는 값으로 대체할 때 (여기서는 *)


아래는 구현한 관련 코드입니다.

          if($is_admin == 'super'){
            $s_name = $list[$i]['wr_name']; //성명
            $s_tel = $list[$i]['wr_subject']; //연락처
          } else {
            $s_name = str_pad(substr($list[$i]['wr_name'],0,3),strlen($list[$i]['wr_name']),"*"); //성명
            $s_tel = str_pad(substr($list[$i]['wr_subject'],0,9),strlen($list[$i]['wr_subject']),"*"); //연락처
          }
          if($list[$i]['wr_10'] == '접수'){
            $stat_color = "background-color:#4caf50;color:#fff";
          } else if($list[$i]['wr_10'] == '상담중'){
            $stat_color = "background-color:#2196f3;color:#fff";
          } else {
            $stat_color = "background-color:#f44336;color:#fff";
          }


아래는 위 코드를 화면에 반영하는 코드입니다.

<td class="td_name sv_use"><?php echo $s_name ?></td>
<td><?php echo $s_tel ?></td>
<td class="td_num" style="<?php echo $stat_color;?>" ><?php echo $list[$i]['wr_10'] ?></td>


댓글목록 0

등록된 댓글이 없습니다.