/    Sign up×
Community /Pin to ProfileBookmark

Dynamic Comment Boxes: Hard to get correct $_POST

this code is in a while loop which dynamically creates a comment box for each thread in a type of forum; multiple threads are seen on the same page with multiple comment boxes.

[code=html]<textarea wrap=”soft” name=”<?=$rowzero?>” rows=”2″ cols=”25″></textarea>
<input type=”submit” name=”submit” value=”OK” />[/code]

$rowzero is an integer and associates the comment box to the post, and is gathered from the DB when the thread loads. When user clicks submit, then $_POST[$rowzero] should contain the text for the comment, but my problem is after a submit $rowzero is NULL. I tried putting the code that adds the comment to the DB AFTER $rowzero is accessed from the DB, which means I have to reload the page to see the comment updated. This is unacceptable. I need a way to realize which $_POST[##] I should be accessing for the comment.

Any suggestions?

Thanks in advance,
Tyler

PS> To clarify, when user hits submit $_POST makes an associative array of all the comment boxes on the page, most of which contain nothing. I was thinking of some type of loop to see which one had something, but my $rowzero is int(11) so that could be prohibitive, and POST is associative.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@auxoneauthorMay 16.2008 — I figured it out. Sometimes typing it all is the best way to get your thoughts straight.. I just added a hidden field that had the number of the $_POST[] I needed, so now it sends two variables.
×

Success!

Help @auxone 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.4,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...