Jump to content

[SOLVED] Loop counter


Trium918

Recommended Posts

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

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

//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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.