Jump to content


Photo

update records problem


  • Please log in to reply
3 replies to this topic

#1 xtiancjs

xtiancjs
  • Members
  • PipPipPip
  • Advanced Member
  • 47 posts

Posted 07 March 2006 - 11:42 PM

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 syntax
xtian

#2 php_b34st

php_b34st
  • Members
  • PipPipPip
  • Advanced Member
  • 168 posts

Posted 07 March 2006 - 11:55 PM

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:

<?php

$new = $existing_votes + $new_votes;

$sql = mysql_query("UPDATE brokers
            SET value_votes
            WHERE value_votes = '$new'");
            
?>


#3 master82

master82
  • Members
  • PipPipPip
  • Advanced Member
  • 182 posts

Posted 08 March 2006 - 12:10 AM

You have the same problem as me, let me know how it goes?

#4 TylerL

TylerL
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 08 March 2006 - 12:41 AM

Show your current code and it'll be easier to help you. It's probably a syntax error.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users