【发布时间】:2014-02-21 13:21:45
【问题描述】:
我想在 mysql 数据库中搜索在日期范围内插入的产品列表。 假设我有一个名为 product 的表,其中包含:id、name、brand 和 datecreated,我可以在 mysql 中执行此操作:
select id, name, brand, datecreated
from product
where datecreated between '2013-09-12' and '2013-10-10'
order by datecreated desc;
这显然会在 Mysql 或 php 中返回所需的结果。
但是,我想在 select 语句中定义日期范围,并使用一个表单来询问用户的起止日期。也不确定方法是什么?
<form action="?" method="">
<div id="dates">
<label for="searchdates">Enter your dates here:</label>
<br>
<label for="fromdate">From:<textarea id="fromdate" name="fromdate" rows="1" cols="5"></textarea></label>
<lablel for="todate">To:<textarea id="todate" name="todate" rows="1" cols="5"></textarea></label>
</div>
<div><input type="submit" value="Search"/></div>
</form>
所以我不确定如何将表单中用户定义的日期范围添加/插入到 select 语句中以返回定义的日期范围内的数据?
干杯 恶作剧
【问题讨论】: