How to place multiple form elements from a loop
You could try this if I understand correctly:

$header = '&lt;table&gt;';
$header .= '&lt;tr&gt;&lt;td&gt;Something...&lt;/td&gt;&lt;/tr&gt;';

$form['header'] = array(
  '#markup' =&gt; $header;
)

$i = 1;

foreach($somethingAwesome as $val){

    $form['blah_' . $i] = array(
        '#type' =&gt; 'textfield';
        '#prefix' =&gt; '&lt;tr&gt;&lt;td&gt;'
        '#suffix' =&gt; '&lt;/td&gt;&lt;/tr&gt;'
    );

$i++;
}

$footer = '&lt;tr&gt;&lt;td&gt;Something else...&lt;/td&gt;&lt;/tr&gt;';
$footer .= '&lt;/table&gt;';

$form['footer'] = array(
    '#markup' =&gt; $footer,
);


This should give you the output:

Something...

TEXTFIELD
TEXTFIELD
TEXTFIELD

Something else...

You'll need to do something to differentiate each $form['blah'] part too, otherwise you'll be running a foreach loop that overwrites that specific part of your form on every iteration.

You're running your foreach loop in the place where you want it, but all of the data you want surrounding the form is being put into one variable, and then added in one go as a prefix.  Suffix will add data to the end.

General Reference (in case you didn't know):

FormAPI Reference

Specific References:

#prefix

#suffix