使用PHP在页面中生成动态数量的元素

Ive got an form-group with some text-inputs. Users are free to fill arbitrary number of fields.

After filling the form, its passed to a php processor which is in charge of creating & populating the template.

I'm having problem creating a proper grid/template for positioning different number of elements in page, which arises because of variety of filled elements by users.

Following is the result of a try:

<p class="header">
    <b>Header which the user has token</b>
</p>
<br />
<!-- Number of a tags is based on number of filled fields-->
<a href="#field1"><p>Theme from the user</p></a>
<a href="#field2"><p>Theme from the user</p></a>
<a href="#field3"><p>Theme from the user</p></a>
<br />
<a name="field1">
    <h2>Text from the user who filled up the textinput</h2>
</a>
<br />
<a name="field2">
    <h2>Text from the user who filled up the textinput</h2>
</a>
<br />
<a name="field3">
    <h2>Text from the user who filled up the textinput</h2>
</a>

Does anyone has similar experience? I'd appreciate any creative idea.