I'm putting my club's membership database online.
I have a Member table in the database with fields such as FirstName, LastName etc. I have a web form with matching input variables Member_FirstName, Member_LastName that's going to be used for inserting a new member into the database, so I'll be populating an SQL statement such as
insert Member
(FirstName, LastName .... )
values
("$_POST['Member_FirstName']", "$_POST['Member_LastName']" ...)
My plan was to have a set of intermediate variables
$Member_FirstName = $_POST['Member_FirstName'];
$Member_LastName = $_POST['Member_LastName'];
so that I could have a pre built SQL statement that would simply substitute the intermediate variables.
OK - that's the background...now the question is, how do I generate the intermediate variables in a loop of column names.
So in pseudo code...
for each $col (select * from Member)
$var = "Member_" . $col; ($var="MemberFirstName")
${$var} = $_POST[$var]; Create the intermediate variable
This is the problem line!
I've been trying to use 'eval()' but can't get the syntax correct, so any views on correct syntax or a better/alternative way to do this appreciated.
Jerry