adam291086 Posted April 5, 2009 Share Posted April 5, 2009 i have my input names set to date1 date2 and i want to set up a little loop to get that data for example $number = 10; while($i<$number) { $date = $_POST['date'.$i.]; $1++ } i keep getting an internal server error why? Link to comment https://forums.phpfreaks.com/topic/152667-solved-looping/ Share on other sites More sharing options...
Alecdude Posted April 5, 2009 Share Posted April 5, 2009 I'd recommend using a for loop. for($duck=1;$duck<=10;$duck+=1) { //code here, will be looped 10 times } Link to comment https://forums.phpfreaks.com/topic/152667-solved-looping/#findComment-801756 Share on other sites More sharing options...
adam291086 Posted April 5, 2009 Author Share Posted April 5, 2009 yeah but how can i get the post data? Link to comment https://forums.phpfreaks.com/topic/152667-solved-looping/#findComment-801757 Share on other sites More sharing options...
corbin Posted April 5, 2009 Share Posted April 5, 2009 $1++ should be $i++ (or ++$i) And you could use date[] as your input names, and it would be an array instead of having to do that ghetto loop. Then you could do foreach($_POST['date'] as $key => $value). Link to comment https://forums.phpfreaks.com/topic/152667-solved-looping/#findComment-801758 Share on other sites More sharing options...
adam291086 Posted April 5, 2009 Author Share Posted April 5, 2009 thanks, used corbins method Link to comment https://forums.phpfreaks.com/topic/152667-solved-looping/#findComment-801763 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.