Trium918 Posted February 20, 2007 Share Posted February 20, 2007 I am trying to get this for loop to count when the user click the count button and I want to know why doesn't it work. for ($i = 1; $i <= 7; $i++) { print "$i"; echo "<form>"; } echo "<input type=\"button\" value=\"Count\">"; echo "</form>"; Link to comment https://forums.phpfreaks.com/topic/39382-solved-loop-counter/ Share on other sites More sharing options...
hvle Posted February 21, 2007 Share Posted February 21, 2007 and? Link to comment https://forums.phpfreaks.com/topic/39382-solved-loop-counter/#findComment-189958 Share on other sites More sharing options...
corbin Posted February 21, 2007 Share Posted February 21, 2007 if($_GET['count']) { for ($i = 1; $i <= 7; $i++) { print "$i"; } } echo "<form action="">"; echo "<input type=\"button\" value=\"Count\" name=\"count\">"; echo "</form>"; That should work. Link to comment https://forums.phpfreaks.com/topic/39382-solved-loop-counter/#findComment-189959 Share on other sites More sharing options...
Trium918 Posted February 21, 2007 Author Share Posted February 21, 2007 I am trying to get this for loop to count when the user click the count button and I want to know why doesn't it work. I am still unable to get this loop to count when the button is clicked. for ($i = 1; $i <= 7; $i++) { print "$i"; echo "<form>"; } echo "<input type=\"button\" value=\"Count\">"; echo "</form>"; Link to comment https://forums.phpfreaks.com/topic/39382-solved-loop-counter/#findComment-190171 Share on other sites More sharing options...
Trium918 Posted February 21, 2007 Author Share Posted February 21, 2007 if($_GET['count']) { for ($i = 1; $i <= 7; $i++) { print "$i"; } } echo "<form action="">"; echo "<input type=\"button\" value=\"Count\" name=\"count\">"; echo "</form>"; I tried it this way but the only thing that shows is the button. That should work. Link to comment https://forums.phpfreaks.com/topic/39382-solved-loop-counter/#findComment-190174 Share on other sites More sharing options...
tom100 Posted February 21, 2007 Share Posted February 21, 2007 You have quotes inside of the echo string and your form isn't posting anywhere. if ($_GET['count']) { for ($i = 1; $i <= 7; $i++) { print "$i"; } } ?> <form action="THISFILE.php" method="GET"> <input type="button" name="count" value="count"> </form> Link to comment https://forums.phpfreaks.com/topic/39382-solved-loop-counter/#findComment-190176 Share on other sites More sharing options...
Trium918 Posted March 1, 2007 Author Share Posted March 1, 2007 I am trying to get a FOR LOOP to run through an ARRAY when the count button is click. Everytime that the Submit button is clicked, I would like the page to refresh with the next ARRAY One , Two , Three etc. $remark[1] = "One"; $remark[2] = "Two"; $remark[3] = "Three"; $remark[4] = "Four"; $remark[5] = "Five"; $remark[6] = "Six"; $remark[7] = "Seven"; $run = " "; if(){ for ($i = 1; $i <= 7; $i++) { print "$i $remark[$i]<br> \n"; } } echo "<form>"; echo "<input type=\"button\" name=\"run\" value=\"Submit\">"; echo "</form>"; Link to comment https://forums.phpfreaks.com/topic/39382-solved-loop-counter/#findComment-196501 Share on other sites More sharing options...
neo777ph Posted March 1, 2007 Share Posted March 1, 2007 //Try this.. //use a hidden text field that would be used to pass the counter.. //example..if user passes 1 then print one.. //hope i helped you. $valuecheck = $_GET['INSERTYOURVALUEHERE']; $remark[1] = "One"; $remark[2] = "Two"; $remark[3] = "Three"; $remark[4] = "Four"; $remark[5] = "Five"; $remark[6] = "Six"; $remark[7] = "Seven"; $run = " "; if(){ for ($i = 1; $i <= 7; $i++) { if( $valuecheck == $i){ print "$i $remark[$i]<br> \n"; }//end innerif }//end loop }//end if echo "<form method=GET action='thisfile.php'>"; echo "<input type='button' name='run' value='Submit'>"; echo "<input type='hidden' name='hidden' value='INSERTYOURVALUEHERE'>"; echo "</form>"; Link to comment https://forums.phpfreaks.com/topic/39382-solved-loop-counter/#findComment-196504 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.