[thelist] Using a PHP variable as a column name in a MySQL statement

NanHarbisonSmith at aol.com NanHarbisonSmith at aol.com
Mon May 27 17:32:00 CDT 2002


--
[ Picked text/plain from multipart/alternative ]
Hi Everyone,
I am thinking this is not possible, I have tried to do it various ways, using
parenthesis, double and single. I am trying to create a page to update a
MySQL table based on what is submitted in a form. I probably did not design
the table well, and now I can't make it work.
The situation:
I do a website for a summer swim club where parents have to volunteer to work
at meets, scoring, writing ribbons, timing the swimmers, etc. I created a
form for parents to sign up for meets, and that was easy, but then we
realized that we need to allow people to change a timer, scorer, etc., and so
I created another form where you choose the position where you want to
substitute one parent for another, so the position (positions are columns in
one table), the person being replaced, the new person being entered and the
date of the meet are really all I need to update the table, except the table
column name is a variable, and I keep getting parse errors, and I know
everything else is okay on this page. Can I not say:
$Query = UPDATE $TableName SET $position = '$replacement' WHERE meet_date =
'$meetdate'";
where position is the position chosen on the form?
TIA,
Nan

Nan Harbison Smith
481 Elm Street
Concord, MA 01742
978-369-1224
978-369-1681

Give a man a fish and you feed him for a day; teach him
to use the Internet and he won't bother you for weeks.





More information about the thelist mailing list