업데이트할때

업데이트할때

QA

업데이트할때

답변 2

본문

그누x쵸딩입니다.

 

업데이트할 때

 



$price = $_POST['price'];
$qty = $_POST['qty'];
$wr_12 = $_POST['wr_12'];

 

$sql = " update g5_write_bbb set 

price = '$price', qty = '$qty', total_price = '$price'+'$qty'  where wr_12 = '$wr_12' ";

sql_query($sql); 

 

price+qty값을  total_price에 집어넣고 싶습니다.

어떠게 해야 할까요?

빨간색으로 하니 안되네요,,,,ㅋ

 

이 질문에 댓글 쓰기 :

답변 2


$price = $_POST['price'];
$qty = $_POST['qty'];
$wr_12 = $_POST['wr_12'];

 

$sum = (int)$price+(int)$qty;

 

$sql = " update g5_write_bbb set 

price = '$price', qty = '$qty', total_price = '$sum'  where wr_12 = '$wr_12' ";

sql_query($sql); 

 

으로 하시면되는데

왠지 

$qty 는 수량 $price는 단가면

$sum = (int)$price * (int)$qty 가 되어야 할겁니다.

두 변수값 더한 제3의 변수 정의 후 집어넣으세요.

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 123,671
© SIRSOFT
현재 페이지 제일 처음으로