ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Maybe, you should use a different name in the loop for the $query variable
because each time you make a mysql_fetch_assoc passing $query variable, the variable content has been modified inside the loop.
Hope this will help you.
In the example that you gave the variable $query was used to assist with two tasks simultaneously. First the collection of the different browsers held on the stats table and then then to gather the number of rows there are on that table. Because you had used the same variable name for both tasks when it returned to the while condition it was looking at the reply from the second sql call not the first. That is why you need to have two distinct variable names.
The "group by" will sort the result into groups, when it is used with aggregate functions, in this case count(*) the result is to give you the value of all the elements in that group, so by grouping by browser you will get the count of all the rows for each specific browser.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.