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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.