I'm writing a calendar, and I want to find a number of rows that within that date. For example, I want to find how many posts occured on the 1st, how many topics occured on the 1st, how many posts occured on the 2nd, so on so forth.
Currently I'm looping through the month while i'm displaying and running the queries on each day.
These are just some of the queries that the page is using:
Ideally what I would be able to do, is have two queries done before I start looping through the rows that I would be able to associate in an array.
If you have any idea how to help limit the queries necessary, please let me know.
Currently I'm looping through the month while i'm displaying and running the queries on each day.
These are just some of the queries that the page is using:
Code:
[1] => SELECT count(*) FROM topics WHERE DATEDIFF('2009-04-02',`dateadded`) = 1 [2] => SELECT count(*) FROM posts WHERE DATEDIFF('2009-04-02',`postdate`) = 1 [3] => SELECT count(*) FROM topics WHERE DATEDIFF('2009-04-03',`dateadded`) = 1 [4] => SELECT count(*) FROM posts WHERE DATEDIFF('2009-04-03',`postdate`) = 1 [5] => SELECT count(*) FROM topics WHERE DATEDIFF('2009-04-04',`dateadded`) = 1 [6] => SELECT count(*) FROM posts WHERE DATEDIFF('2009-04-04',`postdate`) = 1 [7] => SELECT count(*) FROM topics WHERE DATEDIFF('2009-04-05',`dateadded`) = 1 [8] => SELECT count(*) FROM posts WHERE DATEDIFF('2009-04-05',`postdate`) = 1 [9] => SELECT count(*) FROM topics WHERE DATEDIFF('2009-04-06',`dateadded`) = 1 [10] => SELECT count(*) FROM posts WHERE DATEDIFF('2009-04-06',`postdate`) = 1 [11] => SELECT count(*) FROM topics WHERE DATEDIFF('2009-04-07',`dateadded`) = 1 [12] => SELECT count(*) FROM posts WHERE DATEDIFF('2009-04-07',`postdate`) = 1 [13] => SELECT count(*) FROM topics WHERE DATEDIFF('2009-04-08',`dateadded`) = 1 [14] => SELECT count(*) FROM posts WHERE DATEDIFF('2009-04-08',`postdate`) = 1 [15] => SELECT count(*) FROM topics WHERE DATEDIFF('2009-04-09',`dateadded`) = 1 [16] => SELECT count(*) FROM posts WHERE DATEDIFF('2009-04-09',`postdate`) = 1 [17] => SELECT count(*) FROM topics WHERE DATEDIFF('2009-04-10',`dateadded`) = 1 [18] => SELECT count(*) FROM posts WHERE DATEDIFF('2009-04-10',`postdate`) = 1 [19] => SELECT count(*) FROM topics WHERE DATEDIFF('2009-04-11',`dateadded`) = 1
If you have any idea how to help limit the queries necessary, please let me know.
Comment