我有六个下拉菜单用于选择两个日期我有以下代码,无论我选择哪个日期,它都不会给我任何结果
$year1 = $_POST['year1'];
$month1 = $_POST['month1'];
$day1 = $_POST['day1'];
$date1 = $year1 . "/" . $month1 . "/" . $day1;
$year2 = $_POST['year2'];
$month2 = $_POST['month2'];
$day2 = $_POST['day2'];
$date2 = $year2 . "/" . $month2 . "/" . $day2;
$result = mysql_query("SELECT * FROM services WHERE date between '%" . $date1 . "%' AND '%" . $date2 . "%' ORDER BY id " );
但是如果我用特定日期替换最后一行中的变量 $date1 和 $date2 我会得到正确的结果。
$result = mysql_query("SELECT * FROM services WHERE date between '2012/10/01' AND '2012/11/12' ORDER BY id " );
谁能告诉变量 $date1 和 $date2 有什么问题?