liamoco Posted November 23, 2010 Share Posted November 23, 2010 Hello, I want to get all field names from a table called `profileInfo_choose` where field names = 1 AND user_id=$user_id How is this done? Or what is the best way if a single query cannot do the job? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/219595-getting-field-names/ Share on other sites More sharing options...
mikosiko Posted November 23, 2010 Share Posted November 23, 2010 Hello, I want to get all field names from a table called `profileInfo_choose` where field names = 1 AND user_id=$user_id How is this done? Or what is the best way if a single query cannot do the job? Thanks you want the "FIELD NAMES" ?.... based on a condition where you are already using some of the field names?.... no make any sense.... maybe you are trying to get all the rows (values) where the condition is TRUE ?... post your table description Quote Link to comment https://forums.phpfreaks.com/topic/219595-getting-field-names/#findComment-1138578 Share on other sites More sharing options...
liamoco Posted November 23, 2010 Author Share Posted November 23, 2010 user_id | fullName | dob | gender | relationship | looking | hometown | ---------------------------------------------------------------------------------------- 5 | 1 | 1 | 1 | 0 | 0 | 1 | OK getting down to what I want to accomplish is to get all the field names that = 1 where user_id='5' Quote Link to comment https://forums.phpfreaks.com/topic/219595-getting-field-names/#findComment-1138589 Share on other sites More sharing options...
mikosiko Posted November 23, 2010 Share Posted November 23, 2010 your objective no make sense ... you should think again about your goal ... and think based on how SQL works... apparently what you want is select all the records where user_id = 5 and then you can choose to show or not the fields if the value = 1 (the name of the field is irrelevant because you can alter it every time you want (aliasing) ). Quote Link to comment https://forums.phpfreaks.com/topic/219595-getting-field-names/#findComment-1138629 Share on other sites More sharing options...
mikosiko Posted November 23, 2010 Share Posted November 23, 2010 complementing my previous answer... you should look for the usage of mysql_field_name() and use it in the previous explained context. http://php.net/manual/en/function.mysql-field-name.php hope this help. Quote Link to comment https://forums.phpfreaks.com/topic/219595-getting-field-names/#findComment-1138639 Share on other sites More sharing options...
fenway Posted November 25, 2010 Share Posted November 25, 2010 It looks like you're using these as flags -- if so, they should be in another table, and that way, you can simply search for "where any attribute is set", and you don't have to get back field names. Quote Link to comment https://forums.phpfreaks.com/topic/219595-getting-field-names/#findComment-1139535 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.