RE: [PHP] passing random variables names
| From: | Ford, Mike [LSS] | Date: | Fri, 07 Nov 2003 10:08:28 +0000 |
| Subject: | RE: [PHP] passing random variables names | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-168817@lists.php.net to get a copy of this message | ||
On 07 November 2003 08:41, Yonatan Ben-Nes wrote:
> Hi all,
>
> I made a form which pass constant variables which never
> change (Ex. product_name) and dynamic variables which i
> withdraw from the db (Ex. attribute_id = 1, value = color).
> Now my problem is with the passing of the dynamic variables.
> Because the fields can change their name (id's) i need to
> design my functions so they will "know" how to receive them.
> I used to make an array in the form (Ex. attribute_id[0],
> attribute_id[1] where the numbers in the [] are the id
> numbers from the db) and then at the function i used to
> $_POST['attribute_id'] and then withdraw from them their id's and
> values. I read that this kind of passing variables is making problems
> with javascripting
Only if you want to do certain things, and then only if you don't understand the relevant
features of JavaScript ;)
> (and maybe it violate W3C standards).
It doesn't.
> Is there a way that i can pass names like attribute_id_X
> where X is the changing name and the function will be able to
> withdraw it like $_POST['attribute_id_X'], or any other way
> which doesnt violate W3C standards?
Stick to what you're doing -- it's the best PHP-wise, and causes only minimal
inconvenience in your JavaScript in certain well-defined cases.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211