Jump to content

Loop through database table


cmb

Recommended Posts

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 

 

Link to comment
https://forums.phpfreaks.com/topic/250485-loop-through-database-table/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.