将表单数据发布到同一页面时出错

时间:2013-09-18 16:55:43

标签: php mysql

我列出了一些信息。其中一个字段是submit_date,其中包含提交申请的日期。在这个列表的顶部,我想创建一个表单,在下拉菜单中我们可以选择初始日期和最终日期,然后列表将只显示在该时间范围之间提交的应用程序。我得到sql工作并制作表单但由于某种原因,每当我点击提交时,整个列表消失。

<form name="yearRange" action="index.php" method="post">
        Year1:
        <select name="year1">
            <option value="2010">2010</option>
            <option value="2011">2011</option>
            <option value="2012">2012</option>
            <option value="2013">2013</option>
            <option value="2014">2014</option>
           </select>
        Month1:
        <select name="month1">
            <option value="01">January</option>
            <option value="02">February</option>
            <option value="03">March</option>
            <option value="04">April</option>
            <option value="05">May</option>
            <option value="06">June</option>
            <option value="07">July</option>
            <option value="08">August</option>
            <option value="09">September</option>
            <option value="10">October</option>
            <option value="11">November</option>
            <option value="12">December</option>
        </select>
        Day1:
        <select name="day1">
            <option value="01">1</option>
            <option value="02">2</option>
            <option value="03">3</option>
            <option value="04">4</option>
            <option value="05">5</option>
            <option value="06">6</option>
            <option value="07">7</option>
            <option value="08">8</option>
            <option value="09">9</option>
            <option value="10">10</option>
            <option value="11">11</option>
            <option value="12">12</option>
            <option value="13">13</option>
            <option value="14">14</option>
            <option value="15">15</option>
            <option value="16">16</option>
            <option value="17">17</option>
            <option value="18">18</option>
            <option value="19">19</option>
            <option value="20">20</option>
            <option value="21">21</option>
            <option value="22">22</option>
            <option value="23">23</option>
            <option value="24">24</option>
            <option value="25">25</option>
            <option value="26">26</option>
            <option value="27">27</option>
            <option value="28">28</option>
            <option value="29">29</option>
            <option value="30">30</option>
            <option value="31">31</option>
        </select>

        Year2:
        <select name="year2">
            <option value="2010">2010</option>
            <option value="2011">2011</option>
            <option value="2012">2012</option>
            <option value="2013">2013</option>
            <option value="2014">2014</option>
        </select>
        Month2:
        <select name="month2">
            <option value="01">January</option>
            <option value="02">February</option>
            <option value="03">March</option>
            <option value="04">April</option>
            <option value="05">May</option>
            <option value="06">June</option>
            <option value="07">July</option>
            <option value="08">August</option>
            <option value="09">September</option>
            <option value="10">October</option>
            <option value="11">November</option>
            <option value="12">December</option>
        </select>
        Day2:
        <select name="day2">
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
            <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="9">9</option>
            <option value="10">10</option>
            <option value="11">11</option>
            <option value="12">12</option>
            <option value="13">13</option>
            <option value="14">14</option>
            <option value="15">15</option>
            <option value="16">16</option>
            <option value="17">17</option>
            <option value="18">18</option>
            <option value="19">19</option>
            <option value="20">20</option>
            <option value="21">21</option>
            <option value="22">22</option>
            <option value="23">23</option>
            <option value="24">24</option>
            <option value="25">25</option>
            <option value="26">26</option>
            <option value="27">27</option>
            <option value="28">28</option>
            <option value="29">29</option>
            <option value="30">30</option>
            <option value="31">31</option>
        </select>

        <input type="submit" name="submit" value="Submit" />
    </form>

 <?php

if ($DBConn->numRows() > 0) { ?>

        <div align="center">
        <table border="1" align="center">
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td><strong>Name</strong></td>
            <td><strong>Submit Date</strong></td>

        </tr> <?php

            $date1="";
            $date2="";
        if(isset($_POST['year1']) && isset($_POST['year2']) && isset($_POST['month1']) && isset($_POST['month2']) && isset($_POST['day1']) && isset($_POST['day2']))
        {
            $date1 = $_POST['year1']."-".$_POST['month1']."-".$_POST['day1'];
            $date2 = $_POST['year2']."-".$_POST['month2']."-".$_POST['day2'];
        }
        else{
            echo "error";
        }

           $query = "select * from table1 where submit_date > '$date1' AND submit_date < '$date2'";
        $sortQuery = mysql_query($query);
            while ($row1=mysql_fetch_assoc($sortQuery))
            {

            ?>

                <tr>

                    <td valign="top"><?php echo $row1['lname'] . ", " . $row1['fname'] . " " . $row1['mname']; ?></td>

                    <td valign="top"><?php echo date('Y-m-d', strtotime($row1['submit_date'])); ?></td>



            <?php } ?>
            </tr> <?php 
         ?>
        </table> 
        </div>
       <?php
        } ?>

0 个答案:

没有答案