Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- Choosing row name dynamically


The_Hat - 3:21 pm on Apr 29, 2010 (gmt 0)


I need to dynamically specify the name of the row in my database I want to pull out..

For instance, here is what I am wanting to do..

## $targetTable: this variable changes
## $primary: this variable changes
## $primaryValue: this changes
## $rowName: this changes


$result = mysql_query("SELECT * FROM ".$targetTable." WHERE ".$primary." LIKE '".$primaryValue."'");
while($row = mysql_fetch_array($result)) {
$want = $row['$rowName'];
echo $want ;
}


All the variables get stated higher up in the code but I don't seem able to specify dynamically what the name of the row is I want the data from.. I'm sure it's just syntax, i.e. doubleQuote-period-quote.. something or other.. but I sure can't suss it out..

Any help guys?


Thread source:: http://www.webmasterworld.com/php/4124405.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com