dynamic column query mysql
I am trying to make a script where I can query for a column that changes depending on a passed variable. So I have a variable passed called division, lets say it will be a, b, c or d.. I want to get the value in the column division_value1. I initially tried:
but it didn't work and I feel it's probably not what I should be trying.. Any suggestions would be appreciated
$row = mysql_fetch_array($query)
$result = $row[$division . 'value1']
I realize this is 4 years old but I am trying the same thing, did you ever get an answer?
Hey - I don't know if I solved it (sorry) - I think I may have just pulled all columns then compared them in php since there wasn't that many to go through..
Originally Posted by mikednnz
Well, it looks like the OP left out the underscore, but I have no idea if that has anything to do with your problem (or was, in fact, his only problem). I'd suggest posting some details and showing us what code you have tried so far?
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
How to Ask Questions the Smart Way
(not affiliated with this site, but well worth reading)
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread