2013-04-08 6 views
-2

와 수학을하는 데 도움이 필요 나는이 다음 JQuery와/자바 스크립트는 PHP와 자바 스크립트

<script> 
       var Quantity; 
$("select").change(function() { 
    var str = ""; 
    var price = <?php echo $row[price];?>; 
    $("select option:selected").each(function() { 
       str += $(this).text() + " "; 
      }); 
    $(".plan_price").text("price : " + parseInt(str) * price + " baht"); 
    Quantity = parseInt(str); 
}).change(); 
    </script> 

이 PHP/SQL에 대한

if ($row[item_amount] - 1 == 0) { 
       $sql = "update item set active='2',item_amount=item_amount-1,buy_time=NOW() where id='$id'"; 
      } else { 
       $sql = "update item set item_amount=item_amount-1,buy_time=NOW() where id='$id'"; 
      } 

나는 나를 위해 어떤 방법이 있는지 알고 싶어요 PHP에서 $ row [item_amount]와 자바 스크립트 변수 Quantity의 값을 뺄셈/더하기 위해 Quantity를 데이터베이스에서 뺄 필요가 있습니다.

+2

_note : 자바 스크립트를 PHP에 포함시킬 수 있지만 javascipt_ –

+0

안에 PHP를 포함 할 수 없습니다. 그게 무슨 뜻입니까? – vodich

+1

단순히 PHP 변수 값을 javascript 변수에 할당 할 수 있다는 것을 의미하지만 반대의 경우는 가능하지 않습니다. –

답변

0

ajax 호출을 통해 $ row [item_amount]와 상호 작용할 수 있습니다. 직접 Quantity을 (를) $row[item_amount] (으)로 뺄 수 없습니다.

+0

ohhh thats는 어렵거나, 다른 일을하는 다른 방법에 대한 어떤 제안이든지 들린다. '(this is very hard haha ​​:( – user2234873

+1

haha ​​very funny . –