/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] $_POST question

What is the proper format to write:

print $_POST[$row[‘Link_Num’]]_checkbox;

Obviously the above did not work

to post a comment
PHP

11 Comments(s)

Copy linkTweet thisAlerts:
@GarySJul 24.2006 — It's okay as far as

print $_POST[$row['Link_Num']];

... but not sure what the "_checkbox" part is for. Could you say more about what you're trying to do?
Copy linkTweet thisAlerts:
@Vectorman211Jul 24.2006 — Looks like he's trying to concatenate a variable name which I call "variable variables".

You do it like this:
[code=php]
print ${$_POST[$row['Link_num']].'_checkbox'};
[/code]
Copy linkTweet thisAlerts:
@firmanauthorJul 24.2006 — Vectorman is close.. What I have in my form is this

<input type="checkbox" name="{$row['Link_Num']}_checkbox" value="{$row['Link_Num']}">

to create the name say 3300_checkbox

Then when I hit submit... I want to print that $_POST{variable} however I should put it together.
Copy linkTweet thisAlerts:
@GarySJul 24.2006 — Are the curly brackets needed?

Looks like you need something like:

print ($_POST[$row['Link_num'].'_checkbox'] );

.... but worth checking the output of print_r($_POST) to check for the presence (or otherwise) of curly brackets.
Copy linkTweet thisAlerts:
@firmanauthorJul 24.2006 — Are the curly brackets needed?

Looks like you need something like:

print ($_POST[$row['Link_num'].'_checkbox'] );

.... but worth checking the output of print_r($_POST) to check for the presence (or otherwise) of curly brackets.[/QUOTE]



the part that I know "is wrong" in your code is .'_checkbox' I am not adding checkbox.... the POST Value if I am expecting is 3200_checkbox or "something"_checkbox. I need it to be """_$POST(LINK_NUM)_checkbox""" to put it in "simpler" terms.
Copy linkTweet thisAlerts:
@Vectorman211Jul 24.2006 — I see i see. That's a problem because you have no way to index the variable from the post array. Is this like a bunch of checkboxes that are enumerated? If so I would do like this:

[code=php]
//FORM:
print "<input type="checkbox" name="checkbox[{$row['Link_Num']}]" value="{$row['Link_Num']}">";

//UPON SUBMIT:
foreach($_POST['checkbox'] as $checkbox){
print "$checkboxn";
}
[/code]


That way all the checkboxes will be in one array. ?
Copy linkTweet thisAlerts:
@firmanauthorJul 24.2006 — what do you mean index the post variable? I can because the way I make my post variable is from my database and then I add on _checkbox. So I do know what all my POST variables will be. If I can make this work, it would be great... if not, I might have to go by your other post.
Copy linkTweet thisAlerts:
@firmanauthorJul 25.2006 — I figured it out!


print $_POST[$row["Link_Num"].'_checkbox'];


thank you to all who helped!!!
Copy linkTweet thisAlerts:
@Vectorman211Jul 25.2006 — I still have no idea what you're trying to do lol but I'm glad you got it ? Probably would have made more sense if I saw all the code ;P
Copy linkTweet thisAlerts:
@GarySJul 25.2006 — 
print $_POST[$row["Link_Num"].'_checkbox'];
[/QUOTE]


Are you saying this worked and this...


print ($_POST[$row['Link_num'].'_checkbox'] );
[/QUOTE]


... didn't?

Strange.
Copy linkTweet thisAlerts:
@firmanauthorJul 25.2006 — yes... I believe the single quotes errored out. I know it is weird..but that is what happened
×

Success!

Help @firman spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...