Drupal 6: integer field, how to output the value + a 3% up for a field, programmatically I have a production website with a content type that has 3 integer fields. Now the website owner wants to raise those values in a 3%. Since there are hundreds of nodes for that content type, is there a way to modify the output in a 3% via a PHP snippet?
The actual values can be updated. To increase the values by 3% you could use a snippet like the following and run it once, say in a hook_cron, then remove it after the update is complete.

// Create a list of nodes of the required type
$result = db_query("SELECT nid FROM {node} n WHERE n.type = 'YourContentTpe'");
// Iterate through the list
foreach($result as $row) {
   // Load each node
   $node = node_load($row-&gt;nid);
   // Calculate your fields
   $node-&gt;field_1[0]['value'] = 1.03 * $node-&gt;field_1[0]['value'];
   // .. repeat for each field ..
   // Then save the node
   node_save($node);
}


This assumes that all the field values are set. To be rigorous, you should probably check this on each field before attempting to access them. This method uses Drupal functions to keep track of the updates, but hundreds of node_load and node_save functions could significantly impact your server performance while the code is being run.

To just display the altered information without changing the values in the database, You could create three computed fields, and use each to display the value in its base field incremented by 3% as suggested by Human love. This will probably lead to confusion in the future if new nodes are added and the author forgets to reduce the entered information by 3% to have it display correctly.

As much as I hate to advocate it, if this is a one-time update of the information, the most efficient method both in terms of your effort and of server resources would be direct manipulation of the database. Just make sure you back up the database before proceeding,:

UPDATE node n JOIN content_type_{YourContentType} f on n.nid = f.nid set f.field_field_1_value=(1.03 * f.field_field_1_value), f.field_field_2_value=(1.03 * f.field_field_2_value) WHERE n.type='YourContent_type';


for each of your fields. This assumes that the fields are exclusive to the content type. If the field is shared between content types, the field will appear in its own table and the above query should be modified accordingly.