Jump to content

[SOLVED] Return database items between certain dates


ashburnham

Recommended Posts

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...

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.