pacome Posted June 17, 2007 Share Posted June 17, 2007 Hello... I'm retrieving info from a DB and would like to echo the name of the fields that the info comes from. I've got no prob with the info from the fields themselves, but if I want to say what is the field the info is coming from, I'm lost. I've got a table with all the users in it. I can query to see how much money they have, but some have and some don't, so i only want to print those who have got some value in the field, and name them... let's say Jhon | Mary | Lucy | Robert 200 | 120 | | 50 I can get 200, 120, and 50... but how do you go about getting the names and associate them with the amount? thanks! Quote Link to comment https://forums.phpfreaks.com/topic/55950-printing-the-field-names-too/ Share on other sites More sharing options...
trq Posted June 17, 2007 Share Posted June 17, 2007 Are you saying you have fields named John, Mary, Lucy etc etc. Seems a very odd db design. Quote Link to comment https://forums.phpfreaks.com/topic/55950-printing-the-field-names-too/#findComment-276347 Share on other sites More sharing options...
pacome Posted June 17, 2007 Author Share Posted June 17, 2007 I changed the table to what I was advised to in the forum a few days ago, cause I used to have a table for each user in order to retrieve info easily from individual users... it's a snnoker players table! I've got all of the player in it them there... when a user is registerd, he goes into a table of users... I write there his nick, his pass, and i'ts assigned some money, and the field for each of the top 20 snooker players in the world.. so that they can buy and sell "stocks" and increase or decrease the number of stocks the have... I would like to show something like: "My Stocks" and print let's say... User Stocks Player | Stocks Ronnie O'Sullivan | 5 Steve Davis | 0 Graeme Dott | 6 John Higgins | 2 so I know how to get the values 5, 0, 6, 2... but I want to print also the names of the players, only if the numbers of stocks are > 0... so I need to get an array from the users table with the pair name of player, number of stocks... you can see the web at snookermarket thank for your reply Quote Link to comment https://forums.phpfreaks.com/topic/55950-printing-the-field-names-too/#findComment-276352 Share on other sites More sharing options...
trq Posted June 17, 2007 Share Posted June 17, 2007 SELECT Player, Stocks FROM UserStocks WHERE Stocks > 0 Quote Link to comment https://forums.phpfreaks.com/topic/55950-printing-the-field-names-too/#findComment-276362 Share on other sites More sharing options...
pacome Posted June 17, 2007 Author Share Posted June 17, 2007 Thank you.. I will try this! Sure my collegues from snooker will appreciate your help! Quote Link to comment https://forums.phpfreaks.com/topic/55950-printing-the-field-names-too/#findComment-276366 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.