Jump to content

Echoing multiple fields depending on a variable


Andrew R

Recommended Posts

Hi, I need some help echoing a certain amount of fields depending on how much the variable, $total_user equals.

For example if [code]$total_user = ‘6‘[/code] it will echo the below fields (name, age forms six times)

[code]<table width="306" border="0" cellpadding="2" cellspacing="3">
  <!--DWLayoutTable-->
  <tr>
    <td width="45" height="28" valign="middle"><strong>Name:</strong></td>
    <td width="144" valign="top"><input name="name" type="text" id="name"></td>
    <td width="32" valign="middle"><strong>Age:</strong></td>
    <td width="48" valign="top"><select name="select">
        <option value="13">13</option>
        <option value="14">14</option>
        <option value="15">15</option>
        <option value="16">16</option>
        <option value="17">17</option>
        <option value="18">18</option>
        <option value="19">19</option>
        <option value="20">20</option>
      </select></td>
    <td width="1">&nbsp;</td>
  </tr>
</table>[/code]

Can this be done using?  [code]<?php do { ?> ?[/code]

Also how would I label each field so that they can be entered into the database, i.e the input name.

Cheers
For example if the variable equals 4 people, 4 fields will appear and the input name for each field will be :
input name="User_1"  value="bob"
input name="User_2"  Value="andy"
input name="User_3"  Value="sam"
Input name="User_4"  Value="jim"
etc

so this will match up with the database structure

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.