$sql = "select * from tmp_info_all where active = $value4 and getway = $value3 and latesttime between '2012-07-31' and '2012-08-31';";
我想用php从文本框中获取两个时间放在between and 之间,应该怎样写?

解决方案 »

  1.   

    先建立表单页面。让表单页面提交。
    form.php
    <form action="handle.php" method="post">
    <input type="text" name="start">
    <input type="text" name="end">
    <input type="submit">
    </form>handle.php:
    $start=$_POST['start'];
    $end=$_POST['end'];
    $sql = "select * from tmp_info_all where active = $value4 and getway = $value3 and latesttime between '$start' and '$end';";
    ............................
      

  2.   

    我试了,不好用,between and 之间直接放时间好用,用变量不好用,这是为什么呢