在此代码中,我将日期格式 这是我的代码...... p>
结果: p>
dd-mm-yy code>转换为
YY-MM-DD 代码>。 当我从 code>日期回显
$时,它会给出正确的日期(
2017-6-1 code>)。 与
echo $ to code>类似。
但是,当我回显查询时,它无法从 code>获取
$的值,但是
$ to code>它正确地获取日期。 来自 code>的
$有什么问题? p>
< script language ='javascript'>
jQuery(function($)
{
$(“#from”)。datepicker({dateFormat:'dd-mm-yy'});
$(“#to “).datepicker({dateFormat:'dd-mm-yy'});
});
< / script>
< input name =”from“id =”from“type =”text“ />
< input name =“to”id =“to”type =“text”/>
<?php
$ froms = $ _POST ['from'];
list($ day,$ month,$ year)= explode(“ - ”,$ froms);
$ from =“$ year- $ month- $ day”;
$ too = $ _POST ['to'];
list($ day,$ month,$ year)= explode(“ - ”,$ too);
$ to =“$ year- $ month- $ day”;
if($ from =“ $ year- $ month- $ day“&& $ to =”$ year- $ month- $ day“)
{
echo”select * from students where(enquiry_date in'$ from'和'$ to ')“;
}
?>
code> pre>
select * from students where (在'1'和'2017-06-09'之间的enquiry_date)由student_id订购
code> pre>
div>
In this code I am converting date format dd-mm-yy
to yy-mm-dd
. When I echo $from
date it gives the correct date (2017-6-1
). Similarly with echo $to
.
But when I echo the query it can't get value of $from
, but $to
it gets the date correctly. What is the problem with $from
?
Here is my code...
<script language='javascript'>
jQuery(function($)
{
$("#from").datepicker({ dateFormat: 'dd-mm-yy' });
$("#to").datepicker({ dateFormat: 'dd-mm-yy' });
});
</script>
<input name="from" id="from" type="text" />
<input name="to" id="to" type="text" />
<?php
$froms = $_POST['from'];
list($day, $month, $year) = explode("-", $froms);
$from = "$year-$month-$day";
$too = $_POST['to'];
list($day, $month, $year) = explode("-", $too);
$to = "$year-$month-$day";
if($from = "$year-$month-$day" && $to = "$year-$month-$day")
{
echo "select * from students where (enquiry_date between '$from' and '$to')";
}
?>
Result:
select * from students where (enquiry_date between '1' and '2017-06-09') order by student_id