Populating dynamic HTML fields with multidimensional array
<p>I have a form that I created with rows of input fields that are created dynamically.  </p>

<pre><code>foreach ($data as $k =&gt; $v){
print "&lt;tr&gt;Table # $k&lt;/tr&gt;";
print "&lt;tr&gt;&lt;td&gt;First Name&lt;/td&gt;&lt;td&gt;Last Name&lt;/td&gt;&lt;/tr&gt;"

    for($i = 1; $i &lt;= $data[$k]['tickets']; $i++){
        print "&lt;tr&gt;&lt;td&gt;&lt;input name='fname[]' type='text' class='mid_text_data'  value=".$prefill[$k]['first_name']." maxlength='15' /&gt;&lt;/td&gt;&lt;td&gt;&lt;input name='lname[]' type='text' class='mid_text_data'  value=".$prefill[$k]['last_name']." maxlength='15' /&gt;&lt;/tr&gt;";
    }
}
</code></pre>

<p>I've created the input fields based on the number of 'tickets' in my $data array, but I would like to prefill the values of fname with $prefill[$k]['first_name']. </p>

<p>My $prefill and $data variables look like:</p>

<pre><code>$prefill = {
[145]=&gt; array(9) { 
    ["first_name"]=&gt; string(5) "John" 
    ["last_name"]=&gt; string(6) "Doe" 
    ["company"]=&gt; string(10) "Big Business" 
    ["email"]=&gt; string(21) "jdoe@email.org" 
    ["photo_op"]=&gt; int(0) 
    ["gala"]=&gt; int(1) 
    ["chairman"]=&gt; int(0) 
    ["prefix"]=&gt; NULL 
    ["table_number"]=&gt;int(60)
} 
[146]=&gt; array(9) { 
    ["first_name"]=&gt; string(5) "Jane" 
    ["last_name"]=&gt; string(6) "Doe" 
    ["company"]=&gt; string(10) "Big Business" 
    ["email"]=&gt; string(21) "JaDoe@email.org" 
    ["photo_op"]=&gt; int(0) 
    ["gala"]=&gt; int(1) 
    ["chairman"]=&gt; int(0) 
    ["prefix"]=&gt; NULL 
    ["table_number"]=&gt;int(60)
} 
[147]=&gt; array(9) { 
    ["first_name"]=&gt; string(5) "Stan" 
    ["last_name"]=&gt; string(6) "Derp" 
    ["company"]=&gt; string(10) "Big Business" 
    ["email"]=&gt; string(21) "sderp@email.org" 
    ["photo_op"]=&gt; int(0) 
    ["gala"]=&gt; int(1) 
    ["chairman"]=&gt; int(0) 
    ["prefix"]=&gt; NULL 
    ["table_number"]=&gt;int(83)
} 
</code></pre>

<p>} </p>

<pre><code>$data = { 
[60]=&gt; array(5) { 
    ["tickets"]=&gt; int(10) 
    ["gala"]=&gt; int(8) 
    ["chair"]=&gt; int(2) 
    ["ind_id"]=&gt; float(805879) 
    ["photo"]=&gt; int(0) 
} 
[83]=&gt; array(5) { 
    ["tickets"]=&gt; int(5) 
    ["gala"]=&gt; int(5) 
    ["chair"]=&gt; NULL 
    ["ind_id"]=&gt; float(805879) 
    ["photo"]=&gt; int(1) 
} 
</code></pre>

<p>} </p>

<p>Currently, the form repeats 'John' to each one of my 'fname' fields. </p>

<p>Any ideas how to prefill the fields properly?</p>

<p>Thank you.</p>
