Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Two options could be: </p> <p>You could make the date select values include the start and finish with a delimiter that you can explode them into an array on, eg. </p> <pre><code> &lt;option value="2013-12-02:2013-12-02"&gt;Week 5&lt;/option&gt; $dates = explode(':', $_POST['week']); $start_date = $dates[0]; $end_date = $dates[1]; </code></pre> <p>OR </p> <p>Given that your weeks will probably always be the same length you could use either php or mysql date functions to add the required number of days to the start date in order to generate the finish date. eg. <a href="http://us3.php.net/manual/en/datetime.add.php" rel="nofollow">http://us3.php.net/manual/en/datetime.add.php</a> or <a href="http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-add" rel="nofollow">http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-add</a> This second option is probably the better of the two, eg. in php if you have the week start date and want the end date you can do </p> <pre><code>$date = new DateTime($_POST[entryweek1]); $date-&gt;add(new DateInterval('P7D')); $finish_date = $date-&gt;format('Y-m-d') </code></pre> <p>Or you don't event need to generate it in php if you are not using anywhere else in that part of the script, you can just do something like the following in mysql:</p> <pre><code>SELECT * from supervisor ... where workdate BETWEEN '2013-10-01' AND DATE_ADD('2013-10-01', INTERVAL 7 DAY); </code></pre> <p>(regardless of which option you choose in the end, make sure you sanitize the $_POST input before you feed it into your sql as you do above - even though it is coming from a select list you can't guarantee that someone won't manually feed some data into the post to perform an sql injection attack)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload