Trying to convert db_fetch_object for Drupal 7 I am trying to convert a line of code from Drupal 6 for Drupal 7

for ($i = 0; $order = db_fetch_object($result); ++$i) {


Above is what it is -- and below is what I made it  

for ($i = 0; foreach ($result as $order); ++$i) {


BUT . . . I get a parse error:


  Parse error: syntax error, unexpected 'foreach' (T_FOREACH), expecting
  ';' in / [PATH TO FILE] on line 483


Which is this 

for ($i = 0; foreach ($result as $order); ++$i) {


SQL syntax checkers find no error in the syntax - I only a novice
the syntax is incorrect, and the error is correct. If you need to track $i, you could do something like:

$i = 0;
foreach($result as $order){
  ...
  $i++;
}