Avatar of David Schure
David Schure

asked on 

Filtering by Date

I am trying to filter a report based on the month from a select box.
The query for the report
$sql = <<<EOT
    SELECT DATE_FORMAT(tbl_session.session_date,"%W, %M, %d, %Y") AS DATE, 
   TIME_FORMAT(CONCAT(tbl_session.time_slot_id, ":00:00"), "%h:%i %p") AS TIME,
   tbl_session.session_type AS TYPE, tbl_therapist.therapist_name as THERAPIST, tbl_session.session_status AS STATUS
    FROM tbl_session
    INNER JOIN tbl_therapist
    ON tbl_therapist.therapist_id=tbl_session.therapist_id
   WHERE tbl_session.client_id=$client_id
AND tbl_session.session_date = (NOT SURE WHAT GOES HERE)
    ORDER BY session_date DESC;
$result = $db->query($sql);

Open in new window

The selectbox
<form action="monthselect.php">
  <label for="monthly">Select a Month</label>
  <select name="monthly" id="monthly">
     <option value="All">Show All</option>
    <option value="Jan">January</option>
    <option value="Feb">February</option>
    <option value="Mar">March</option>
    <option value="Apr">April</option>
    <option value="May">May</option>
    <option value="Jun">June</option>
    <option value="Jul">July</option>
    <option value="Aug">August</option>
    <option value="Sept">September</option>
    <option value="Oct">October</option>
    <option value="Nov">November</option>
    <option value="Dec">December</option>
   <input type="submit" value="Submit"> 

Open in new window

I know I need to add an Ajax script and populate the monthselect.php file.  Not sure how.
      $('select[name=monthly]').on('change', function() {

    let selectedValue = $(this).val()
        url : 'monthselect.php',
        data : { client : selectedValue },
    }).done(function(response) {


Open in new window


Avatar of undefined
Last Comment
David Schure

8/22/2022 - Mon