Andrew R Posted October 13, 2006 Share Posted October 13, 2006 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"> </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 Link to comment https://forums.phpfreaks.com/topic/23877-echoing-multiple-fields-depending-on-a-variable/ Share on other sites More sharing options...
tleisher Posted October 13, 2006 Share Posted October 13, 2006 for ($i = 1; $i <= $total_count; $i++){ // Do stuff here} Link to comment https://forums.phpfreaks.com/topic/23877-echoing-multiple-fields-depending-on-a-variable/#findComment-108481 Share on other sites More sharing options...
Daniel0 Posted October 13, 2006 Share Posted October 13, 2006 What do you mean by labelling them? Link to comment https://forums.phpfreaks.com/topic/23877-echoing-multiple-fields-depending-on-a-variable/#findComment-108483 Share on other sites More sharing options...
Andrew R Posted October 13, 2006 Author Share Posted October 13, 2006 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 Link to comment https://forums.phpfreaks.com/topic/23877-echoing-multiple-fields-depending-on-a-variable/#findComment-108497 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.