djfox Posted October 30, 2007 Share Posted October 30, 2007 I`m sure there`s a way to do it. Let`s say I have a table called "table" and it has the fields "id", "name", "number". And let`s say it currently has 100 entries but it grows in number of entries. When I click I a button in a form, I want the field "number" changed to something else to all the entires. How is this accomplished? Quote Link to comment Share on other sites More sharing options...
sdi126 Posted October 30, 2007 Share Posted October 30, 2007 Will the field number be the exact same for all entries? Or Will the field number be the same just for the newly inserted rows? Quote Link to comment Share on other sites More sharing options...
djfox Posted October 30, 2007 Author Share Posted October 30, 2007 The output should be different for each entry. Ie, id 1 might have number = 500 but id 2 might have number = 100. I will have a form made (which I can do no problem) which I will enter a number, say, 50, and the code needs to subtract that number from all entries in he field "number". So "number" is different for all entries and will have a different output as well. So from the example, if I want to subtract 50, the result should be that it will update the fields: id 1 number 450 id 2 number 50 Quote Link to comment Share on other sites More sharing options...
sdi126 Posted October 30, 2007 Share Posted October 30, 2007 The sql code would be something like: I am just going to assume you are using mysql. mysql_query("update table set number = (number - " .$_REQUEST["numberFromForm"].")"); Quote Link to comment Share on other sites More sharing options...
djfox Posted October 30, 2007 Author Share Posted October 30, 2007 Ah thanks very much! :3 Quote Link to comment 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.