Jump to content

$_POST in for loop?


canabatz

Recommended Posts

i need to loop 130 times and post data

 

what is the way to do it?

 

i tryed this ,but it's not working

for ($c=0; $c<=129; $c++){

if($_POST['data'] == $_POST['data.$c']) 


}

 

i need to have it like that:

 

$_POST['data'] == $_POST['data0']

$_POST['data'] == $_POST['data1']

$_POST['data'] == $_POST['data2']

$_POST['data'] == $_POST['data3']

 

130 times!

 

what im doing wrong?

 

Link to comment
https://forums.phpfreaks.com/topic/185593-_post-in-for-loop/
Share on other sites

Not 100% sure if this works, but you added the wrong syntax to your loop. "<" is lessthan, so it'll just not loop.

for ($c=0; $c>=130; $c++){
   echo $_POST['data'] == $_POST['data'.$c];
}

 

But what is this code for? From the looks of it.. It could be accomplished a much simpler way. You forgot colons and what is the if for?

Link to comment
https://forums.phpfreaks.com/topic/185593-_post-in-for-loop/#findComment-979829
Share on other sites

it's working sorry ,i had a break; in some part of the loop!!

 

 

thanx

 

if($_POST['data'] == $_POST['data'.$c]) is working!

 

Yep. Just remember variables don't resolve in single quotations. That's why you had to concatenate it after the 'data'.

Link to comment
https://forums.phpfreaks.com/topic/185593-_post-in-for-loop/#findComment-979848
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.