Hi, thanks for your reply 🙂
I was unable to work out how to get your code to work, so I tried another approach that kinda worked.
$month = 1;
while($month < 13){
// make the query to get the postings
$query = "SELECT Affiliate_ID FROM stats WHERE Affiliate_ID=$_SESSION[affiliate_id] AND date LIKE '2006-0$month%'";
// run the query
$result = @mysql_query ($query) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $query . "<br />\nError: (" . mysql_errno() . ") " . mysql_error());
// get the number of rows
$num = mysql_num_rows($result);
echo '<p>',$query;
echo "<td align=\"center\" class=\"row1\"><span class=\"link\">$num</span></td>";
$month++;
}
However, because my date format is being stored like:
2006-08-16 14:34:12
I added an extra '0' into the query to combat this, however this has caused a problem when it is looking for the 10,11 & 12th months, cause the query is now doing this:
SELECT Affiliate_ID FROM stats WHERE Affiliate_ID=2 AND date LIKE '2006-010%'
SELECT Affiliate_ID FROM stats WHERE Affiliate_ID=2 AND date LIKE '2006-011%'
SELECT Affiliate_ID FROM stats WHERE Affiliate_ID=2 AND date LIKE '2006-012%'
How can I get it to drop the zero when the month is 10,11,12 ?