ashburnham Posted November 26, 2007 Share Posted November 26, 2007 Example of my customers database is as follows: idorder_daterefer 101/09/2007Bill 223/11/2007Bob 309/11/2007Steve 408/10/2007Bob 523/11/2007Dave 630/10/2007Dave 715/11/2007Bob At the moment I have managed to extract the data and display the number of occurrences of the refer by using the following code: @mysql_select_db("database") or die( "Unable to select database"); $query = "SELECT refer, COUNT(refer) AS occurrence FROM customers GROUP BY refer ORDER BY occurrence DESC"; $result = mysql_query($query); $num=mysql_numrows($result); echo "<table border='1' cellpadding='0' cellspacing='1' bgcolor='#B9D1FF' bordercolor='#0000FF'> <tr> <td><font color='#0000FF'><strong>Referrer</strong></font></td> <td><font color='#0000FF'><strong>Occurrences</strong></font></td> </tr>"; $i=0; while ($i < $num) { $referrer=mysql_result($result,$i,0); $number=mysql_result($result,$i,1); echo"<tr> <td><strong>$referrer</strong></td> <td>$number</td> </tr>"; $i++; } echo "</table>"; mysql_close; } Which gives a nice little table like: ReferrerOccurrences Bob3 Dave2 Bill1 Steve1 ...but I'm looking to enhance this to do the same as above but between certain dates that the user puts in. I don't have problem with the form just how to handle the data (i.e. between $date1 and $date2). Many thanks for your help... Quote Link to comment Share on other sites More sharing options...
toplay Posted November 26, 2007 Share Posted November 26, 2007 Your i.e. example is exactly what you can use. See MySQL manual page for using "BETWEEN" keyword: http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_between Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 26, 2007 Share Posted November 26, 2007 The dates will need to be stored in the database as a DATE data type first. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.