Jump to content

Counting Grouped Table Column Results


phprocker

Recommended Posts

Hey all.  I have a database table that adds the date every time someone clicks on a specific link.  So if 5 people click on this link on January 10 it will add 5 Jan 10th dates to the "click_date" column and so forth.

 

So, I'm retrieving this lists of dates from the database table and grouping them with the GROUP BY statement.  This is fine and the dates get listed all grouped but how can I list the number of rows each group has?

 

So it lists like this:

Jan 10th    -      5 Clicks

Jan 11th    -      3 Clicks

 

Here's the code I'm using:

sql = "SELECT * FROM clicktrack WHERE link='$link' GROUP BY click_date";

 

So I have no problem listing the dates as so:

Jan 10th

Jan 11th

 

But I need the number in each group of dates.

 

Thanks.  8)

Link to comment
https://forums.phpfreaks.com/topic/189543-counting-grouped-table-column-results/
Share on other sites

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.