Jump to content

[SOLVED] Referring to mysql columns using variables


carlg

Recommended Posts

I have the following code:

 

$query = "SELECT  * FROM table";
$result = mysql_query($query);
while ($row  = mysql_fetch_assoc($result)){
     print $row['$variable'];
}

 

What is the proper syntax to use on this line?

print $row['$variable'];

 

This code is part of a function and the column that I want to print is variable based upon which parameter is passed in.

 

Thanks

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.