Hi, I'm wondering if someone can help me with a little PHP
problem I'm having at the moment?
I think it might be one of the fundamentals of the language
that I'm not understanding but I'm hoping that someone
might be able to help me anyway.
Basically I'm writing an online database editing script
which includes a form validation part. The script handles
multiple database tables with different fields and settings
by including different files which have an array which stores
all the relevant information for each different table, for
example:
$userTableFields[0]["field"] = "id";
$userTableFields[0]["type"] = "";
$userTableFields[1]["field"] = "type";
$userTableFields[1]["type"] = "text";
... etc etc...
Summing my problem up to the best of my poor technical knowledge,
my main problem involves the referencing of arrays through the
contents of other variables... I think!
My problem is that I would like to reference variables passed
through a <form>, not referencing them individually by name,
but by using a for loop to traverse through the fields required
to be validated by the form validation routine and check them
individually. My gripe is with lines of code similar to this:
$nameoffieldtocheck = $userTableFields[$i]["field"];
// above line should return a string, eg. "address"
echo $nameoffieldtocheck." = ".$GLOBALS[$nameoffieldtocheck];
So I'm wanting the script to return the word "address" to the
the browser followed by what is actually contained in the
$address variable. That doesn't happen. Is this possible at all?
Obviously by another method that I'm not using here?
The reason this needs to be done is because there is a
predefined list of fields but obviously they change for each
table since they are all different so I need to write a routine
that will check the input for anything it's given.
I hope someone can help, if I haven't explained anything
very well, please post back and I'll attempt to elaborate a bit.
Thanks,