I'm wondering if there's any way to put the name of a field into a variable.
I have several fields that have a value of 0, 1 or 2. I want to be able to pull and print the name of each field that has a specified value (either 0, 1 or 2 depending on what I need.)
Any ideas?
Selecting info from a MySQL DB...
Moderator: General Moderators
http://www.php.net/manual/en/function.m ... d-name.php
$colname = mysql_field_name($result, $i);
$i is the offset of the returned fields (starts from zero)
$colname = mysql_field_name($result, $i);
$i is the offset of the returned fields (starts from zero)
Well I cant think of a way of limiting cols based on the name of the column only the data within the column. So maybe you could switch the results based on the mysql_field_name result.
Code: Select all
if ( mysql_field_name($result, $i) <> '0' ){
print "your code here";
}