Jump to content

Count number of days in db by date listed...


siafulinux

Recommended Posts

Okay, here's a quick question. I am somewhat new to PHP but have created an application but am stuck at how to do something.

 

I have a table with entries and a date stamp in mm/dd/yyyy format. I want to count how many days there were but only counting 1 day if there are say 20 entries for one specific day! In other words lets say there are:

 

10 entries for 10/05/2007

and

5 entries for 10/10/2007

The count should result as 2 days.

 

I have tried while loops but they keep causing the browser to not load the page.

Here is an example of what I've tried:

 

// GET THE NUMBER OF DAYS FOR ENTRIES

$query = "SELECT (date) AS date FROM data";

$result = mysql_query($query) or die(mysql_error());

 

// EXECUTE THE ABOVE QUERY

$number = 0;

while ($row = mysql_fetch_array($result)){

while ($row['date'] == $row['date']) {    // Also tried    if ($row['date'] == $row['date']) {

$number = $number + 1;

echo $number;

}

}

 

 

 

Can anyone help with this?

 

Much appreciated.

Siafu

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.