Поэтому я хочу, чтобы пользователь выбирал «неделю» из поля со списком и возвращал две даты (начало и конец этой недели) в инструкцию SQL ….. которая давала бы данные в течение этого недельного периода. Мне нужно только 1 поле со списком, так как эти данные будут доступны только неделями. Как мне это сделать?
Вот мой код:
<form id="weekselectform" name="weekselectform" method="post" action=""> <div id="weekselect"> <table> <tr> <td>Select Week: <select name="dateentryweek" id="entryweek1"> <option value=""></option><option value="2013-07-01">Week 1</option><option value="2013-07-08">Week 2</option><option value="2013-07-15">Week 3</option><option value="2013-07-22">Week 4</option> <option value="2013-07-29">Week 5</option><option value="2013-08-05">Week 6</option><option value="2013-08-12">Week 7</option><option value="2013-08-19">Week 8</option> <option value="2013-08-26">Week 9</option><option value="2013-09-02">Week 10</option><option value="2013-09-09">Week 11</option><option value="2013-09-16">Week 12</option> <option value="2013-09-23">Week 13</option><option value="2013-09-30">Week 14</option><option value="2013-10-07">Week 15</option><option value="2013-10-14">Week 16</option> <option value="2013-10-21">Week 17</option><option value="2013-10-28">Week 18</option><option value="2013-11-04">Week 19</option><option value="2013-11-11">Week 20</option> <option value="2013-11-18">Week 21</option><option value="2013-11-25">Week 22</option><option value="2013-12-02">Week 23</option><option value="2013-12-09">Week 24</option> <option value="2013-12-16">Week 25</option><option value="2013-12-23">Week 26</option><option value="2013-12-30">Week 27</option><option value="2014-01-06">Week 28</option> <option value="2014-01-13">Week 29</option><option value="2014-01-20">Week 30</option><option value="2014-01-27">Week 31</option><option value="2014-02-03">Week 32</option> <option value="2014-02-10">Week 33</option><option value="2014-02-17">Week 34</option><option value="2014-02-24">Week 35</option><option value="2014-03-03">Week 36</option> <option value="2014-03-10">Week 37</option><option value="2014-03-17">Week 38</option><option value="2014-03-24">Week 39</option><option value="2014-03-31">Week 40</option> <option value="2014-04-07">Week 41</option><option value="2014-04-14">Week 42</option><option value="2014-04-21">Week 43</option><option value="2014-04-28">Week 44</option> <option value="2014-05-05">Week 45</option><option value="2014-05-12">Week 46</option><option value="2014-05-19">Week 47</option><option value="2014-05-26">Week 48</option> <option value="2014-06-02">Week 49</option><option value="2014-06-09">Week 50</option><option value="2014-06-16">Week 51</option><option value="2014-06-23">Week 52</option> </select> </td> <td><input type="submit" value="GO" class="button black" id="weekbutton2" /></td> </tr> </table> </div> </form>
Он отправляется на страницу и первоначально был захвачен двумя полями со списком: php:
$inputweek11 = $_POST[entryweek1]; $inputweek22 = $_POST[entryweek2]; $result1=mysql_query(" SELECT Supervisor, COUNT(CASE WHEN DAYOFWEEK(workdate) = 2 THEN 1 END) `Monday`, COUNT(CASE WHEN DAYOFWEEK(workdate) = 3 THEN 1 END) `Tuesday`, COUNT(CASE WHEN DAYOFWEEK(workdate) = 4 THEN 1 END) `Wednesday`, COUNT(CASE WHEN DAYOFWEEK(workdate) = 5 THEN 1 END) `Thursday`, COUNT(CASE WHEN DAYOFWEEK(workdate) = 6 THEN 1 END) `Friday`, COUNT(CASE WHEN DAYOFWEEK(workdate) = 7 THEN 1 END) `Saturday` FROM payroll.employeedatanew_copy JOIN payroll.employeehours ON employeedatanew_copy.`ID Number` = employeehours.employeeid WHERE employeehours.workdate BETWEEN '$inputweek11' AND '$inputweek22' GROUP BY supervisor ");