Have you tried it? I've done this sort of thing before, and it works just fine. By the time the query string is executed, the variables have been interpreted.
So, if $colName = "id", and $id = 12, then your query variable looks something like "select * from myTable where $colName = $id". By the time you get to executing the query, it's been interpolated (?) to "select * from myTable where id = 12". Michael K. Dolan Jr. wrote: > Is it possible to do a sort of dynamic sql. For instance, if I have a form with a >bunch of field/data variables and I send them to a php processor, can I just create a >loop to have it update all the fields without having to specify each field. > > In scratch code, I guess I'm looking for something like this: > > sql = "UPDATE my_table SET $table_field_name = $table_field_value WHERE table_id = >$table_id" > > If you see how I'm trying to make the field name a dynamic variable, then you can >see what I'm trying to do. I have no problem with the dynamic field value, it's just >the dynamic field name that I'm not sure how/if I can create it dynamically. > > Can anyone help with this? Or can anyone tell me it can't be done? > > Thanks > > Mike > > -- Sliante, Richard S. Crawford mailto:[EMAIL PROTECTED] http://www.mossroot.com AIM: Buffalo2K ICQ: 11646404 Yahoo!: rscrawford MSN: [EMAIL PROTECTED] "It is only with the heart that we see rightly; what is essential is invisible to the eye." --Antoine de Saint Exupery "Push the button, Max!" -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]