Couldn't think of a good topic title, sorry.
Anyway, if I create a table called 'blah' and it has fields named dish_size, mat, mount.
Can I define constants like so:
Code: Select all
define('dish_size', 'Size: ');
define('mat', 'Material: ');
define('mount', 'Mounting Bracket: ');
Then when I am creating an admin form to add rows to my table, I can simply pull all the fields from the table and change the "scruffy" field name for a nicely written one on the fly - that way I don't have to hardcode it.
I know that I would simply need to do something like:
Code: Select all
echo mat . '<input type="text" ... />';
but I don't want to do that because it would obviously require me to go through them all and it would be defeating the object, I just want to loop through all the table fields and create a form entry box for each one with the proper field name being put in for each field, but how can I get PHP to recognise I want a variables value exchanging for a constants value.
So if
Code: Select all
$field[0] = 'mat';
echo $field[0]; //would output "Material: ", instead of simply "mat"
That's what I can't get my head around.
I hope you understand what I mean!
Cheers.