CCK field. how to use dynamic names to call CCK fields? (like: $node->$cckname)
You use curly braces {} to delimit the variable inside your reference, as

for($i = 0; $i &gt;= 20; $i++) {
  $cckname = 'field_photos_' . $i; //$cckname is changing the image field name, then...
  echo "&lt;img src='/" . $node-&gt;{$cckname}[0]['filepath'] . "'";
}


This syntax is used in many places in Drupal core, see for example hook_field_prepare_translation.