ryeman98 Posted June 22, 2008 Share Posted June 22, 2008 I want to decrement without having to retrieve the value by selecting and turning it into an array, blah blah blah. How do I do something like this: <?php $update = mysql_query("UPDATE `table` SET amount='{amount-1}' WHERE id='$id'"); ?> Link to comment https://forums.phpfreaks.com/topic/111313-easy-mysql-question/ Share on other sites More sharing options...
trq Posted June 22, 2008 Share Posted June 22, 2008 $update = mysql_query("UPDATE `table` SET amount=amount-1 WHERE id='$id'"); Link to comment https://forums.phpfreaks.com/topic/111313-easy-mysql-question/#findComment-571397 Share on other sites More sharing options...
ryeman98 Posted June 22, 2008 Author Share Posted June 22, 2008 $update = mysql_query("UPDATE `table` SET amount=amount-1 WHERE id='$id'"); Simple enough ... didn't think it would work but I guess I'll try it Link to comment https://forums.phpfreaks.com/topic/111313-easy-mysql-question/#findComment-571398 Share on other sites More sharing options...
trq Posted June 22, 2008 Share Posted June 22, 2008 Thats a great idea. Link to comment https://forums.phpfreaks.com/topic/111313-easy-mysql-question/#findComment-571402 Share on other sites More sharing options...
ryeman98 Posted June 22, 2008 Author Share Posted June 22, 2008 Thats a great idea. Didn't work. amount was 10 and it was supposed to take away 1 but took away all 10. Link to comment https://forums.phpfreaks.com/topic/111313-easy-mysql-question/#findComment-571408 Share on other sites More sharing options...
trq Posted June 22, 2008 Share Posted June 22, 2008 What field type is amount? Link to comment https://forums.phpfreaks.com/topic/111313-easy-mysql-question/#findComment-571451 Share on other sites More sharing options...
Darklink Posted June 22, 2008 Share Posted June 22, 2008 Use INT or DOUBLE. Link to comment https://forums.phpfreaks.com/topic/111313-easy-mysql-question/#findComment-571527 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.