I have a CGI script that I'm developing that dynamically creates form elements along with the HTML content, based on items in a database. Think of it this way -- the page you're looking at was created by pulling this message from a MySQL database. One of the items on this page, right below this message, is probably a Radio Button allowing you to vote on this post. The source code for the HTML will identify this radio button with something similar to
<INPUT type=radio name='vote__37894' value='1'> where 37894 is a unique identifier tied to this record.
Now my CGI isn't going to know to look for vote__37894 or even $query->param('vote__37894'). But if I get a list of all the variables I'm returning, using @names = $ query->param; then I should be able to pattern match against "vote__*" and do something from there based on the wildcard.
So my question is, if I'm passing other things, like comment__37894, how can I build a variable name based on variable content? If a variable exists named vote__foo then I want to update my database with comment__foo where foo is the record number in my database. How do I concatinate "comment__" and the value of "foo", and use that concatinated string as a variable name?
Hoping some of that made sense...
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.