cmb Posted November 5, 2011 Share Posted November 5, 2011 this is my sql code <?php $query = "SELECT Player, SUM(GLI) AS 'gli', SUM(Goals) AS 'goals', SUM(Saves) AS 'saves', SUM(SOG) AS 'sog', SUM(Assists) AS'assists', SUM(CK) AS 'ck', SUM(YC) AS 'yc', SUM(RC) AS 'rc' FROM pinkpanther_stats GROUP BY Player; "; ?> their are 11 separate players and i want to set variables $adam_glie and $tyler_glie equal to the glie column for that player(the player being the first part of the variable) and i dont have any idea how to go about doing this Quote Link to comment https://forums.phpfreaks.com/topic/250485-loop-through-database-table/ Share on other sites More sharing options...
trq Posted November 5, 2011 Share Posted November 5, 2011 Naming variables like that way makes little sense. Quote Link to comment https://forums.phpfreaks.com/topic/250485-loop-through-database-table/#findComment-1285157 Share on other sites More sharing options...
cmb Posted November 5, 2011 Author Share Posted November 5, 2011 do you have any suggestions on how i should do this i know very little Quote Link to comment https://forums.phpfreaks.com/topic/250485-loop-through-database-table/#findComment-1285160 Share on other sites More sharing options...
PFMaBiSmAd Posted November 5, 2011 Share Posted November 5, 2011 And in your existing thread for this task, someone already told you to use generic names for your variables and to process/display the information inside of a loop. Somehow you are stuck on making 11 times too much code, taking probably 44 times more time to write, test, and troubleshoot. I would hate to see your interface/form code that is calling the code you have been posting. If you remember back to the Algebra you took in school, variables are used so that you can write one equation (or code) that operates on different values simply by setting the variable to each new value and getting the corresponding result from the equation (or code.) Edit: frankly, if you would continue this problem in your existing thread, someone trying to help you with the current issue could directly see the things that have already been suggested. Quote Link to comment https://forums.phpfreaks.com/topic/250485-loop-through-database-table/#findComment-1285162 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.