Re: Newbie in Need of Assistance

From: Date: Wed, 24 Oct 2001 19:18:30 +0000
Subject: Re: Newbie in Need of Assistance
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-13685@lists.php.net to get a copy of this message
It´s very easy and to tell you the truth I descovered it by accident: Lets say you have a variable with the dynamic variable name (ej. $var_name = "game1";) if you want to create this variable ($game1) then you can write: $$var_name And that´s it. try it. "Jmack" <joe_mack2000@hotmail.com> escribió en el mensaje news:20011023232006.38834.qmail@pb1.pair.com... > Greetings. I have been playing around with PHP this week, programming a > football pool. I have hit a small snag that I would like some assistance > with, if anyone knows the answer -- it's probably very simple, but my Intro > to PHP book does not tell me how to do it. > > I have an HTML form in a PHP page, with several controls on it. I am > dynamically generating the names for these controls. Here is the example -- > for each game, the user selects the winner in a <SELECT> control. It's set > up to not care how many games there are for each week, just dynamically > build the form/controls and name them "pick1", "pick2", etc. > > In my function that handles the form and uploads the user's picks to the > database (MySQL), I need to also dynamically generate the variable names > that refer to these controls. I have them all declared as global variables, > since I know there will never be more than 15 games in a given week. But, I > want to iterate through a loop for each game and update the database. As I > loop through for each game, and try to dynamically generate the vaiable > names for $pick1, $pick2, etc. I end up trying to update the DB by sending > in the string "$pick1" instead of the value from the form control for pick1. > > I have attached the PHP file in question. The code is not very clean, > especially the part where I am having problems, but hopefully, someone will > have some time to help me with this problem. Please respond to this > newsgroup or directly to me at jmack@macksysinc.com. Thank you. > > Joe Mack > > > >

« previous php.db (#13685) next »