stylin Posted January 17, 2007 Share Posted January 17, 2007 Hi, I want to loop a form name. Incrementing it so that each field has the same input name with a number.It just isn't working, I am new to php so really need some help![code] <?phpfor ($cnt=1; $cnt<=; $i++){ echo "$cnt";}?> <tr> <td> <?php do { ?> <input name="day<?php echo $cnt; ?>" value="<?php echo $row_days['day_name']; ?>"> </td> <td> <input name="mail_drop<?php echo $cnt; ?>" type="text" id="mail_drop" value="" size="10"></td> <td><input name="phone_canvas<?php echo $cnt; ?>" type="text" id="phone_canvas" size="10" value=""> </td> <td><input name="emails_sent<?php echo $cnt; ?>" type="text" id="emails_sent" size="10" value=""></td> <td><input name="appointments_made<?php echo $cnt; ?>" type="text" id="appointments_made" size="10" value=""></td> <td><input name="presentations<?php echo $cnt; ?>" type="text" id="presentations" size="10" value=""></td> <td><input name="bills_analysed<?php echo $cnt; ?>" type="text" id="bills_analysed" size="10" value=""></td> <td><input name="orders<?php echo $cnt; ?>" type="text" id="orders" size="10" value=""></td> <td><input name="deliveries<?php echo $cnt; ?>" type="text" id="deliveries" size="10" value=""></td> <td><input name="referrals<?php echo $cnt; ?>" type="text" id="referrals" size="10" value=""></td> <?php } while ($row_days = mysql_fetch_assoc($days)); ?> </tr> [/code] Link to comment https://forums.phpfreaks.com/topic/34504-looping-a-form-name/ Share on other sites More sharing options...
dgiberson Posted January 17, 2007 Share Posted January 17, 2007 the issue is with the for loop.for ($cnt=1;$cnt<$var;$cnt++){ // echo table rows here} Link to comment https://forums.phpfreaks.com/topic/34504-looping-a-form-name/#findComment-162522 Share on other sites More sharing options...
emehrkay Posted January 17, 2007 Share Posted January 17, 2007 $cnt = 0;do{$cnt++...}while{}remember, do while loop does iterate at least once Link to comment https://forums.phpfreaks.com/topic/34504-looping-a-form-name/#findComment-162527 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.