dongyou6768 2013-09-05 12:12
浏览 30

加入两个表 - php表单根据输入日期显示结果

We have two tables in a database-

  1. 'orderno' with the columns - 'JobNumber' and 'date_col'

  2. 'JOBS' with the colums - 'JobNo' , 'Job_Title' , 'Handler'

JobNumber == JobNo and the 'date_col' shows when the jobs were added on the system.

I want to find the code to create a PHP form where you can input a date, click submit and this would display all the jobs added onto the system that day including the Job_Title and Handler.

Here is the code for the input script:

<title>Jobs Today</title><center>
<h1>Jobs on the System Today</h1>
<p>Please select the date:</p>
</center>
<center>
<form action="jobs_today.php" method="get">
  <p>Day:
    <select name="day" id="day">
      <option selected="selected">01</option>
      <option>02</option>
      <option>03</option>
      <option>04</option>
      <option>05</option>
      <option>06</option>
      <option>07</option>
      <option>08</option>
      <option>09</option>
      <option>10</option>
      <option>11</option>
      <option>12</option>
      <option>13</option>
      <option>14</option>
      <option>15</option>
      <option>16</option>
      <option>17</option>
      <option>18</option>
      <option>19</option>
      <option>20</option>
      <option>21</option>
      <option>22</option>
      <option>23</option>
      <option>24</option>
      <option>25</option>
      <option>26</option>
      <option>27</option>
      <option>28</option>
      <option>29</option>
      <option>30</option>
      <option>31</option>
    </select>
  Month:
    <select name="month" id="month">
      <option selected="selected">01</option>
      <option>02</option>
      <option>03</option>
      <option>04</option>
      <option>05</option>
      <option>06</option>
      <option>07</option>
      <option>08</option>
      <option>09</option>
      <option>10</option>
      <option>11</option>
      <option>12</option>
    </select>
  Year:
    <select name="year" id="year">
      <option selected="selected">2013</option>
      <option>2014</option>
    </select>
  </p>
    <p><span class="cent">
    <input type="submit" name="submit" value="Submit" />
  </span></p>
</form>
</center>

I am looking for the code that is needed for 'jobs_today.php' to display all the jobs added onto the system on the chosen date including the Job_Title and Handler?

Thank you!

  • 写回答

2条回答 默认 最新

  • dongmale0656 2013-09-05 12:34
    关注

    first i suggest using a date picker rather than your select options might save you some effort.

    once you get your submitted data to your php use this select statement to get the results

    $query = "select 'JobNo' , 'Job_Title' , 'Handler', 'date_col' from JOBS j join orderno o on o.JobNumber = j.JobNo where date_col = $submitted_date"
    
    $jobs= mysql_query($query) or die(mysql_error());
    
    while($rows = mysql_fetch_assoc($jobs)){
        foreach($row as $key => $value){
            print "$key: $value\t";
        }
        print "
    ";
    }
    

    have not tested this but should be a good start for you

    评论

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)