채택완료

여분필드의 값이 있으면 임의이 이미지로 대체해서 출력하고 싶습니다.

안녕하세요

 

https://sir.kr/g5_skin/28437?sfl=wr_subject%7C%7Cwr_content&stx=%EB%8B%AC%EB%A0%A5&page=2

이 게시판을 참고해서 달력게시판을 만들고 있습니다.

 

모바일에서 달력을 확인했는데 칸이 좁아서 여분필드로 잡아둔 값이 지저분하게 나와서 값이 있을떄 아이콘으로 출력하고 싶어서 작업중인데 잘 안되서 질문을 남깁니다

 

Copy
if($member[mb_level] == 10){
    $html_day[$i].= "<br /><a href=\"".G5_BBS_URL."/board.php?bo_table={$bo_table}&year={$year}&month={$month}&wr_id={$row['wr_id']}&sc_no={$sc_no}\" id=\"subject_{$j}\" {$showLayer}>{$row['ca_name']}</br>{$row['wr_4']}{$row['wr_5']}{$row['wr_6']}{$row['wr_7']}</a>".$list['comment_cnt'];
}else{
  $html_day[$i].= "<br />{$row['ca_name']}{$row['wr_4']}{$row['wr_5']}{$row['wr_6']}{$row['wr_7']} ".$list['comment_cnt'];
            }

 

이 부분이 달력칸에 데이터를 띄우는 부분인데

wr_4,5,6,7에 데이터가 있으면 각 필드마다 다른아이콘을 출력해주고 싶은데

방법을 알려주시면 감사하겠습니다

|

답변 1개 / 댓글 3개

채택된 답변
+20 포인트

Copy
<?php

if($member[mb_level] == 10){
    $html_day[$i].= "<br /><a href=\"".G5_BBS_URL."/board.php?bo_table={$bo_table}&year={$year}&month={$month}&wr_id={$row['wr_id']}&sc_no={$sc_no}\" id=\"subject_{$j}\" {$showLayer}>{$row['ca_name']}</br>";
    $html_day[$i].= "<br />{$row['ca_name']}";
    if ( $row['wr_4'] ) $html_day[$i].= $row['wr_4'];
    if ( $row['wr_5'] ) $html_day[$i].= $row['wr_5'];
    if ( $row['wr_6'] ) $html_day[$i].= $row['wr_6'];
    if ( $row['wr_7'] ) $html_day[$i].= $row['wr_7'];
    $html_day[$i] .= $list['comment_cnt'];
} else {
    $html_day[$i].= "<br />{$row['ca_name']}";
    if ( $row['wr_4'] ) $html_day[$i].= $row['wr_4'];
    if ( $row['wr_5'] ) $html_day[$i].= $row['wr_5'];
    if ( $row['wr_6'] ) $html_day[$i].= $row['wr_6'];
    if ( $row['wr_7'] ) $html_day[$i].= $row['wr_7'];
    $html_day[$i] .= $list['comment_cnt'];
}

답변에 대한 댓글 3개

답변감사드립니다 작성해주신 코드에서 뒤쪽에 $row['wr_4'] 이부분을 제가 넣으려는 이미지 경로로 바꾸면 여분필드값 대신 아이콘을 출력할수있을까요?
이미지 표시 가능하실꺼예요

[code]

<?php

if($member[mb_level] == 10){
$html_day[$i].= "<br /><a href=\"".G5_BBS_URL."/board.php?bo_table={$bo_table}&year={$year}&month={$month}&wr_id={$row['wr_id']}&sc_no={$sc_no}\" id=\"subject_{$j}\" {$showLayer}>{$row['ca_name']}</br>";
$html_day[$i].= "<br />{$row['ca_name']}";
if ( $row['wr_4'] ) {
// $html_day[$i].= $row['wr_4'];
echo '<img src="path/to/image.png" title="'. $html_day[$i].= $row['wr_4'] .'">';
} else {
// 값이 없을때 처리가 필요하다면 이미지를 항상 표시하지만 값이 있다면 색상이 있는 아이콘 없다면 그레이톤 이미지를 표시하는 방법으로 사용가능합니다.
}
if ( $row['wr_5'] ) {
echo '<img src="path/to/image.png" title="'. $html_day[$i].= $row['wr_5'] .'">';
}
if ( $row['wr_6'] ) {
echo '<img src="path/to/image.png" title="'. $html_day[$i].= $row['wr_6'] .'">';
}
if ( $row['wr_7'] ) {
echo '<img src="path/to/image.png" title="'. $html_day[$i].= $row['wr_7'] .'">';
}
$html_day[$i] .= $list['comment_cnt'];
} else {
$html_day[$i].= "<br />{$row['ca_name']}";
if ( $row['wr_4'] ) {
// $html_day[$i].= $row['wr_4'];
echo '<img src="path/to/image.png" title="'. $html_day[$i].= $row['wr_4'] .'">';
}
if ( $row['wr_5'] ) {
echo '<img src="path/to/image.png" title="'. $html_day[$i].= $row['wr_5'] .'">';
}
if ( $row['wr_6'] ) {
echo '<img src="path/to/image.png" title="'. $html_day[$i].= $row['wr_6'] .'">';
}
if ( $row['wr_7'] ) {
echo '<img src="path/to/image.png" title="'. $html_day[$i].= $row['wr_7'] .'">';
}
$html_day[$i] .= $list['comment_cnt'];
}
[/code]
감사합니다 코드 참고해서 적용완료했습니다 ㅎㅎ

답변을 작성하려면 로그인이 필요합니다.