The Midnighter Posted May 27, 2009 Share Posted May 27, 2009 Ok, so basically.. I thought this was the most simple way of doing this, but its turning out to be a bit of trouble. I can see what I'm doing wrong, Im' just having a brain fart and cannot think of the proper way to do this.. I realize that $current is never going to catch up to $snom at this point.. I have a form, and I am simply trying to add more than one text area, by doing the following: $snom = $_GET['snum']; if (!$snom) { $snom = "1"; $current = "0"; } // If it's not declared yet, declare it.. else if ($snom == "1") { $current = "0"; } // To at least one field else { $current = $snom-1; } // Else add one Then to write it: while ($current != $snum ) { echo "<input name=\"serial\" id=\"serial\" type=\"text\" size=\"40\" />"; $current++; } ?> <a href="index.php?snum=<?php echo $snum+1; ?>">Add item</a> Link to comment https://forums.phpfreaks.com/topic/159854-solved-adding-items-to-a-form/ Share on other sites More sharing options...
The Midnighter Posted May 27, 2009 Author Share Posted May 27, 2009 Solved, had my logic backwards: $current = "0"; $snom = $_REQUEST['snum']; if (!$snom || $snom == "0") { $snom = "1"; } To record, <?php echo ('Current = ' . $current .' Snom = ' . $snom); while ($current < $snom ) { echo "<input name=\"serial\" id=\"serial\" type=\"text\" size=\"40\" />"; $current++; } ?><a href="index.php?snum=<?php echo $snom+1; ?>">Add item</a> To use. Link to comment https://forums.phpfreaks.com/topic/159854-solved-adding-items-to-a-form/#findComment-843097 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.