Jump to content

[SOLVED] pulling things just for TODAY?


galvin

Recommended Posts

I'm getting stuck trying to figure this out and I know it's simple.

 

 

I have a mysql table called 'cases' where each entry has an 'entrydate' field (i.e the date it's entered) in the format of:

 

2009-09-18

 

Each day, I want to pull everything from that table that only has TODAY's date (i.e. the current date).

 

So I know this is close, but what goes where I have "**TODAY***

 

$sqlquery = "SELECT * FROM cases
WHERE entrydate = **TODAY**"; 
$result = mysql_query($sqlquery); 
$numbercases = mysql_numrows($result); 

echo "<span class='numcases'> Today there are $numbercases cases.</span>";

Link to comment
https://forums.phpfreaks.com/topic/174756-solved-pulling-things-just-for-today/
Share on other sites

// if you need the day to not have leading 0s then replace the "d" in the date() method to "j"
//for example this code will format it like this 2009-09-01, but with "j" it will format like this 2009-09-1
$date=date('Y-m-d');
$sqlquery = "SELECT * FROM cases
WHERE entrydate = '$date'";
$result = mysql_query($sqlquery); 
$numbercases = mysql_numrows($result); 

echo "<span class='numcases'> Today there are $numbercases cases.</span>";

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.