chester Posted January 15, 2009 Share Posted January 15, 2009 I have a form of undetermined length. I generate form field names with a loop. On the process page I would like to access the $_Post data with another loop. My attempt does not work: for($i=0; $i<$num_rows; $i++){ $temp = "'update_status".$i."'"; echo $temp."<br>"; echo "Status".$i." : ".$_POST[$temp]."<br>"; } Does anyone have a suggestion on how to do this? Thank you. Link to comment https://forums.phpfreaks.com/topic/140949-solved-variables-within-_post/ Share on other sites More sharing options...
revraz Posted January 15, 2009 Share Posted January 15, 2009 Do you want to access all of the POST data or just ones that start with update_status in the name? Link to comment https://forums.phpfreaks.com/topic/140949-solved-variables-within-_post/#findComment-737740 Share on other sites More sharing options...
rhodesa Posted January 15, 2009 Share Posted January 15, 2009 http://www.phpfreaks.com/forums/index.php/topic,234040.msg1086853.html#msg1086853 Link to comment https://forums.phpfreaks.com/topic/140949-solved-variables-within-_post/#findComment-737744 Share on other sites More sharing options...
chester Posted January 15, 2009 Author Share Posted January 15, 2009 Revraz - If I can get it to work with this field name it should be easy enough to apply it to other ones. Rhodesa - Thank you for that link, it looks like it may be helpful. My form now looks like: echo "<select name=\"update_status[".$i."]\">"; and my process code looks like: for($i=0; $i<$num_rows; $i++){ echo "Status".$i." : ".$_POST['update_status[$i]']."<br>"; } Am I not accessing the array correctly? Link to comment https://forums.phpfreaks.com/topic/140949-solved-variables-within-_post/#findComment-737754 Share on other sites More sharing options...
chester Posted January 15, 2009 Author Share Posted January 15, 2009 Ack put the index in the wrong place. This works: echo "num rows:".$num_rows."<br>"; for($i=0; $i<$num_rows; $i++){ echo "Status".$i." : ".$_POST['update_status'][$i]."<br>"; } Thanks a ton for the help guys! Link to comment https://forums.phpfreaks.com/topic/140949-solved-variables-within-_post/#findComment-737758 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.