-
Jun 24th, 2014, 10:22 AM
#1
Thread Starter
Don't Panic!
[RESOLVED] PHP - $_POST and looping
Hi
Having a play with PHP and MySql.
Got what is probably an easy question : $_POST is an array, so how come I cannot loop it with echo $_POST[<num>]
Where <num> is a number 0 - 7
I used count on $_POST and it is returning 7... And I can get to the values posted from the from with the name...
Just can't see why putting a number in the field doesn't work...
Being thick prolly
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jun 24th, 2014, 10:35 AM
#2
Re: PHP - $_POST and looping
If the count is 7, wouldn't it be 0-6?
That aside, are you getting an error? or just not getting the data?
-tg
-
Jun 24th, 2014, 10:37 AM
#3
Re: PHP - $_POST and looping
also, keep in mind $_POST and $_GET are special animals, and while they sometimes act like arrays, I'm not sure they are. plus the fields could in theory come in any order so there is no guarnatee that $_POST[0] represents the same field each time. Annnnd... you should know what's coming over in your form fields too, so referring to them by name shouldn't be an issue.
-tg
-
Jun 24th, 2014, 11:00 AM
#4
Thread Starter
Don't Panic!
Re: PHP - $_POST and looping
Thanks for the info, guess it is a different beast to the normal array.
0-6 yup, I should be more careful on my post.
Mainly due to me not getting anything in POST when I was expecting it. Took a while to realise that I needed 'name' in the form controls to get the POST to work. But wanted to loop it to see all that it returned.
Not a problem. Still messing around an at procedural stage... The OO/PDO looks a bit confusing and some examples I tried, didn't work. So I thought, get it going in procedural and if people want me to develop more, go on a course or something.
Thanks again
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|