> I'm trying to do something that i'm not sure is even > possible. I want to cycle thru an array of MySQL fieldnames > and dynamically declare variables based on those fieldnames. > > I can create the array of fieldnames no problem, by just > using "describe" with DBI. > > But I can't figure out the declaration part. THis is what > i've tried... > > foreach $i (@fieldlist) { > $$i = $session->get_query_value('$i'); > } > > That doesn't work, although that's the gist of what I'm after. > Fieldnames are like "order_id", bill_fname", "ship_lname", etc. > > If I were to hard-code these declarations, I would have about > 40 lines that look like: > > $order_id = $session->get_query_value('order_id'); > $customer_id = $session->get_query_value('customer_id'); > $bill_prefix = $session->get_query_value('bill_prefix'); > $bill_fname = $session->get_query_value('bill_fname'); > > The $session-> bit is a function that grabs data of the same > name as my fieldnames from an outside sessionfile. > > I am just trying to avoid having to hardcode this stuff in > there, because a) it's alot of code and b) the > fieldnames/session variables will grow and I don't want to > have to edit the script every time. > > Any help is appreciated!
Is this a CGI script? How big is it? Are you familiar with the DBI function bind_columns? If not, here's a link to my favorite DBI/DBD reference: <http://mysql.turbolift.com/mysql/DBD_3.21.X.php3> To appease the powers that be, does anyone know if you can bind columns to a hash: i.e. $sth->bind_columns(undef,\$val{a},\$val{b},\$val{c}); # ? -dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]