SystemOverload Posted September 3, 2009 Share Posted September 3, 2009 PHP 5.2.5 Inside a PHP function, I've returned a set of results from a table, there will only ever been one record. while ($arrAccVerify = mysql_fetch_array($rsAccVerify)) { $fldContactName = $arrAccVerify['contact_name']; return $fldContactName; } but what if I want to return a dynamic field, ie, the field of choosing at the time i call the function, ie: $varReturnField = "contact_email"; while ($arrAccVerify = mysql_fetch_array($rsAccVerify)) { $fldReturnField= $arrAccVerify['$varReturnField']; return $fldReturnField; } I tried this and i just get [Notice: Undefined index: $varReturnField]... Is what I am trying to achieve possible, and if so, how??? Thanks Link to comment https://forums.phpfreaks.com/topic/173040-return-a-dynamic-field-value/ Share on other sites More sharing options...
rhodesa Posted September 3, 2009 Share Posted September 3, 2009 get rid of the single quotes: $varReturnField = "contact_email"; while ($arrAccVerify = mysql_fetch_array($rsAccVerify)) { $fldReturnField= $arrAccVerify[$varReturnField]; return $fldReturnField; } Link to comment https://forums.phpfreaks.com/topic/173040-return-a-dynamic-field-value/#findComment-912057 Share on other sites More sharing options...
SystemOverload Posted September 3, 2009 Author Share Posted September 3, 2009 LMAO - Thanks... I didn't even think about something as simple as that... Who's a moron.... >>ME<< Thank you... Link to comment https://forums.phpfreaks.com/topic/173040-return-a-dynamic-field-value/#findComment-912058 Share on other sites More sharing options...
rhodesa Posted September 3, 2009 Share Posted September 3, 2009 you could have saved yourself a bunch of typing and just used the emoticon: Link to comment https://forums.phpfreaks.com/topic/173040-return-a-dynamic-field-value/#findComment-912060 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.