xtiancjs Posted March 7, 2006 Share Posted March 7, 2006 Hi, I have a table named brokers and am trying to add numbers from a menu to an existing number in a field named value_votes . I tried it with the UPDATE command in sql but this just replaced my old number not added to it. I know I need to do something along these lines: UPDATE brokers SET value_votes WHERE value_votes = existing number + new number from form , that last little bit is over my head, can anybody help me with that syntaxxtian Quote Link to comment https://forums.phpfreaks.com/topic/4384-update-records-problem/ Share on other sites More sharing options...
php_b34st Posted March 7, 2006 Share Posted March 7, 2006 assuming that you have got the exiting number in a variable called $existing_votes and the new number in a variable called $new_votes you could do something like:[code]<?php$new = $existing_votes + $new_votes;$sql = mysql_query("UPDATE brokers SET value_votes WHERE value_votes = '$new'"); ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/4384-update-records-problem/#findComment-15224 Share on other sites More sharing options...
master82 Posted March 8, 2006 Share Posted March 8, 2006 You have the same problem as me, let me know how it goes? Quote Link to comment https://forums.phpfreaks.com/topic/4384-update-records-problem/#findComment-15229 Share on other sites More sharing options...
TylerL Posted March 8, 2006 Share Posted March 8, 2006 Show your current code and it'll be easier to help you. It's probably a syntax error. Quote Link to comment https://forums.phpfreaks.com/topic/4384-update-records-problem/#findComment-15240 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.