Re: $ of variables, php, mysql

From: Date: Tue, 25 Nov 2003 07:28:50 +0000
Subject: Re: $ of variables, php, mysql
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-170853@lists.php.net to get a copy of this message
On Tue, 2003-11-25 at 00:42, Joffrey Leevy wrote: > > Would appreciate in anyone can help me. > > Let's say I do a query in php, eg. $query = "select > shed from structure"; With the mysql_fetch_array > function and a loop I could see all the values stored > in the column, shed, using the command: echo $shed; > > Let's say now that I am carrying over a variable from > a form called $form where $form = shed. I can still > say $query = "select $form from structure"; because > $form = shed. > > The problem I have now is with the strings and how do > I see my column values. > > Using echo $$value; or echo $($value); or echo > \$$value; or echo $"$value"; does not give me the > values stored in the column shed. > > Help anyone? > thanks > > __________________________________ > Do you Yahoo!? > Free Pop-Up Blocker - Get it now > http://companion.yahoo.com/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > I don't understand.. Why would you need a variable variable to retrive an item from the database? If you mean you don't know what column the data is going to come from once the form is submitted can't you just use mysql_fetch_row() instead. Then you don't need to worry much about what column it came from. If there's more then one column you'd need to know order. In the loop you can use something like for($i = 0; $results = mysql_fetch_row($query); $i++) { echo $results[0]; //$results[0] would always retrieve that column queried even if change. } This is off the top of my head. It should work with a little tweaking. -- "I have a photographic memory. I just forgot the film" --Unknown ============================= Ryan Thompson rthomp@sympatico.ca http://osgw.sourceforge.net

« previous php.general (#170853) next »