Jump to content

update records problem


xtiancjs

Recommended Posts

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
Link to comment
https://forums.phpfreaks.com/topic/4384-update-records-problem/
Share on other sites

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]
Link to comment
https://forums.phpfreaks.com/topic/4384-update-records-problem/#findComment-15224
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.