加入两个表 - 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!

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

suppose that the date_col's data type is date

$day=$_POST['day'];
$month=$_POST['month'];
$year=$_POST['year'];

$dateVar=$year.'-'.$month.'-'.$day;

$query="select job_title from orderno,jobs where jobNumber=jobNo and date_col='".$dateVar."'"

ofcourse this query is prone to sql injection, i dont recommend using this query, it is just for demonstation purpose