Running a query using todays date
Posted: Fri Jul 09, 2004 1:30 pm
I am trying to create a query which will use today's date as a parameter. I am using MySQL and Php 4.1. My code thus far is as follows
The table I am running the query against is ttime and the field that holds the date value is TIDATE. I want the query to use the session value of the user SNUM and todays date to pull up the record set.
The practical reason for doing this is the user SNUM adds time records for time spent on various activities throughout the day into the table ttime. My query is intended to allow the user to query the database to create a record set of those records they have added today. I am stumped as to how to get the query to use today's date in the mm/dd/yyyy format as a parameter. Any and All Help is Appreciated!
feyd | Please use
Code: Select all
<?PHP
$result = mysql_query( "SELECT * FROM ttime where (SNUM = '".$_SESSION['SNUM']."') and TIDATE = Date() ORDER BY TIDATE DESC")
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "You currently have $num_rows time entries for today.</font><P>";
?>The practical reason for doing this is the user SNUM adds time records for time spent on various activities throughout the day into the table ttime. My query is intended to allow the user to query the database to create a record set of those records they have added today. I am stumped as to how to get the query to use today's date in the mm/dd/yyyy format as a parameter. Any and All Help is Appreciated!
feyd | Please use
Code: Select all
tags when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]