Michael, Yes. Just go ahead, and echo $sql to see what you have. You can build quite complex queries this way, dependent upon input from picklists, checkboxes, etc., adding and dropping conditions according to whether or not they have been selected/set.
So why not $sql = " UPDATE $fieldlist $wherecondition" ? When we think about it a bit, if we are assigning a SQL statement to $sql, we are passing a dynamic variable to mysql_query(), so why not create it using variables? Cheers - Miles Thompson At 11:58 PM 1/24/2002 -0500, 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 -- 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]