코드 질문입니다.
본문
아래 코드가 맞나요? 계속 에러가 나네요...
<tr>
<?php
if($mb['mb_1'] == '1') { //기업
echo '<th scope="row"><label for="mb_business_no">사업자번호<strong class="sound_only">필수</strong></label></th><td><input type="text" name="mb_business_no" value="<?php echo $mb[mb_business_no] ?>" id="mb_2" class="frm_input" size="25" maxlength="12">';
} elseif ($mb['mb_1'] == '2') {//개인
echo '<th scope="row"><label for="mb_birth">생년월일<strong class="sound_only">필수</strong></label></th><td><input type="text" name="mb_birth" value="<?php echo $mb[mb_3] ?>" id="mb_3" class="frm_input" size="25" maxlength="20"></td></td>';
}
?>
</tr>
답변 3
<tr>
<?php
if ($mb['mb_1'] == '1') { //기업
echo '<th scope="row"><label for="mb_business_no">사업자번호<strong class="sound_only">필수</strong></label></th><td><input type="text" name="mb_business_no" value="'. $mb['mb_business_no'] .'" id="mb_2" class="frm_input" size="25" maxlength="12">';
} elseif ($mb['mb_1'] == '2') {//개인
echo '<th scope="row"><label for="mb_birth">생년월일<strong class="sound_only">필수</strong></label></th><td><input type="text" name="mb_birth" value=' . $mb['mb_3'] . '" id="mb_3" class="frm_input" size="25" maxlength="20"></td></td>';
}
?>
</tr>
or
<tr>
<?php if ($mb['mb_1'] == '1') { ?>
<th scope="row"><label for="mb_business_no">사업자번호<strong class="sound_only">필수</strong></label></th><td><input type="text" name="mb_business_no" value="<?php echo $mb['mb_business_no'] ?>" id="mb_2" class="frm_input" size="25" maxlength="12">
<?php } elseif ($mb['mb_1'] == '2') { ?>
<th scope="row"><label for="mb_birth">생년월일<strong class="sound_only">필수</strong></label></th><td><input type="text" name="mb_birth" value="<?php echo $mb['mb_3'] ?>" id="mb_3" class="frm_input" size="25" maxlength="20"></td></td>
<?php } ?>
</tr>
<?php echo $mb[mb_3] ?> 중간에 이런식인 코드는 <? php 안에 사용은 불가능합니다. 지금 형식이시면 '.$mb[mb_3].' 이런식으로 변경해보세요.
<?php echo $mb['mb_3'] ?>
<?php echo $mb['mb_business_no'] ?>
따옴표를 넣어보세요
답변을 작성하시기 전에 로그인 해주세요.