테스트 사이트 - 개발 중인 베타 버전입니다

db에 내용 더하기 질문입니다. 채택완료

humanb2box 8년 전 조회 1,944

mb_id라는 필드에 2가지 변수를 넣으려면 어떻게 해야하나요?

$sql = " update {$g5['board_new_table']} set mb_id = '$변수+$변수' where wr_id = '$wr_u' ";

이런식으로 하면되나요?

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

답변 1개

채택된 답변
+20 포인트
8년 전

원하는 구분자를 넣어주면 됩니다. ',', '|' 등 

쌍따옴표 안의 변수는 중괄호로 묶어주는 것이 좋습니다.

</p><p><span style="color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;">$sql = " update {$g5['board_new_table']} set mb_id = '{$변수},{$변수}' where wr_id = '$wr_u' ";</span> </p><p><span style="color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;">
</span></p><p><span style="color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;">$sql = " update {$g5['board_new_table']} set mb_id = '{$변수}||{$변수}' where wr_id = '$wr_u' ";</span><span style="color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"> </span></p><p><span style="color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;">
</span></p><p><span style="color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;">....</span></p><p>

예를 들어 첫번째 변수에 ID 'test', 두번째 변수에 3이라는 값이 있다면..

updae g5_board_new set mb_id = 'test||3' where~ 식으로 쿼리가 실행되고 'test||3' 식으로 저장이 됩니다.

로그인 후 평가할 수 있습니다

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

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

로그인