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? Link to comment https://forums.phpfreaks.com/topic/75389-solved-execute-a-certain-deed-to-all-entries-at-once/ 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? Link to comment https://forums.phpfreaks.com/topic/75389-solved-execute-a-certain-deed-to-all-entries-at-once/#findComment-381380 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 Link to comment https://forums.phpfreaks.com/topic/75389-solved-execute-a-certain-deed-to-all-entries-at-once/#findComment-381383 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"].")"); Link to comment https://forums.phpfreaks.com/topic/75389-solved-execute-a-certain-deed-to-all-entries-at-once/#findComment-381392 Share on other sites More sharing options...
djfox Posted October 30, 2007 Author Share Posted October 30, 2007 Ah thanks very much! :3 Link to comment https://forums.phpfreaks.com/topic/75389-solved-execute-a-certain-deed-to-all-entries-at-once/#findComment-381397 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.