Bluehost.com Web Hosting $6.95

$ of variables, php, mysql

This is a discussion on $ of variables, php, mysql within the PHP General forums, part of the PHP Programming Forums category; Would appreciate in anyone can help me. Let's say I do a query in php, eg. $query = "select ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-25-2003
Joffrey Leevy
 
Posts: n/a
Default $ of variables, php, mysql


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/
Reply With Quote
  #2 (permalink)  
Old 11-25-2003
Rt
 
Posts: n/a
Default Re: [PHP] $ of variables, php, mysql

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
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 05:45 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0