Jump to content

Archived

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

xtiancjs

update records problem

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

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites
Show your current code and it'll be easier to help you. It's probably a syntax error.

Share this post


Link to post
Share on other sites

×

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.