$datef = (date("Y-m-d",mktime(0, 0, 0, $_GET['year'], $_GET['month'], $_GET['day'])));
		$datel = (date("Y-m-d",mktime(0, 0, 0, $_GET['year1'], $_GET['month1'], $_GET['day1'])));
		echo $datef.$datel;
		$result = mysql_query("SELECT f8_0, n7_91, t_stamp FROM westdrayton WHERE t_stamp BETWEEN '".$datef."' AND '".$datel."' limit 20");

I have this PHP code to try and grab records from between the two dates in a mysql db. In the database i'm just timestamping every record that comes in.

Any one spot why this code wouldnt work?

Thanks

Recommended Answers

All 5 Replies

I think your error is with your date variables:

$datef = date("Y-m-d",mktime(0, 0, 0, $_GET['year'], $_GET['month'], $_GET['day']));
$datel = date("Y-m-d",mktime(0, 0, 0, $_GET['year1'], $_GET['month1'], $_GET['day1']));

Are you getting any error messages or is it just not grabbing anything from the database? I've just made a guess at what could be wrong since I don't know if you're getting any type of error message.

used this code for that
if (!$Aprilquery)
{
die('MySQL Error: '.mysql_error());
}
thanks for post ur error

This worked in the end!

$datef = (date("Y-m-d",mktime(0, 0, 0, $_POST['month'], $_POST['day'], $_POST['year'])));
				$datel = (date("Y-m-d",mktime(0, 0, 0, $_POST['month1'], $_POST['day1'], $_POST['year1'])));
				$result = mysql_query("SELECT f8_0, n7_91, t_stamp FROM `westdrayton` WHERE t_stamp BETWEEN '".$datef."' AND '".$datel."'");

What is the data type of your t_stamp column? I assume it is TIMESTAMP?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.