scott
07-15-2003, 11:42 PM
Hello,
I'm new to mysql and php, I've been playing around with them for around six months. But it's on and off in my spare time. (that's the heads up) :)
I've created a database for tracking our paper inventory. Basically when an individual takes paper, or envelopes the quantity is entered into the database, along with some other items. This all works great.
I also have two fields that use the "Date" and "Time" types for holding the date and time of the initial transaction.
I've created a seperate php script that we will use for our "end of month" reports. The script goes through and adds up the cost of each "purchase" between a specified time frame (1 may thru 31 may for example).
This script works for me as long as I perform my query with my condition formated as such:
WHERE 1 AND `costcode` = '.$costcode_num.' AND `date` >= \'2003-07-13\' AND `date` <= \'2003-07-14\'
(I left out the begining and ending of the query)
But I need to be able to pass the start date and end date (my search parameter) via a form using the POST action.
When I do this it results in my date being a string...which does not produce any results for me.
I've been testing within my script by setting a variable to some sample dates.
$startdate = '2003-07-13';
$enddate = '2003-07-14';
I've tried a trim() on them, and addslashes(), etc.
I can't seem to get the "string" to give me any results with my query.
I've tried formatting my query as such:
`date` >= '.$startdate.'
I've also tried the following:
`date` >= \"$startdate\"
I just can't seem to figure out how to get this working. I'm guessing it's because I am using the "Date" type for my field.
Is there a way to get this to work...or do I have to change my field type?
I really need to be able to use >= and <= to limit my search queries to be within the dates specified.
I'd appreciate the help if someone could point me in the correct direction for solving my problem.
Thanks,
Scott
I'm new to mysql and php, I've been playing around with them for around six months. But it's on and off in my spare time. (that's the heads up) :)
I've created a database for tracking our paper inventory. Basically when an individual takes paper, or envelopes the quantity is entered into the database, along with some other items. This all works great.
I also have two fields that use the "Date" and "Time" types for holding the date and time of the initial transaction.
I've created a seperate php script that we will use for our "end of month" reports. The script goes through and adds up the cost of each "purchase" between a specified time frame (1 may thru 31 may for example).
This script works for me as long as I perform my query with my condition formated as such:
WHERE 1 AND `costcode` = '.$costcode_num.' AND `date` >= \'2003-07-13\' AND `date` <= \'2003-07-14\'
(I left out the begining and ending of the query)
But I need to be able to pass the start date and end date (my search parameter) via a form using the POST action.
When I do this it results in my date being a string...which does not produce any results for me.
I've been testing within my script by setting a variable to some sample dates.
$startdate = '2003-07-13';
$enddate = '2003-07-14';
I've tried a trim() on them, and addslashes(), etc.
I can't seem to get the "string" to give me any results with my query.
I've tried formatting my query as such:
`date` >= '.$startdate.'
I've also tried the following:
`date` >= \"$startdate\"
I just can't seem to figure out how to get this working. I'm guessing it's because I am using the "Date" type for my field.
Is there a way to get this to work...or do I have to change my field type?
I really need to be able to use >= and <= to limit my search queries to be within the dates specified.
I'd appreciate the help if someone could point me in the correct direction for solving my problem.
Thanks,
Scott