troubleshooting Question

Getting a Selectbox to Filter a Report

Avatar of David Schure
David Schure asked on
4 Comments1 Solution13 ViewsLast Modified:
I am trying to get this selectbox to filter a report. I have this so far.
<form action="">
  <label for="cars">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"> 
The Script
      $('select[name=monthly]').on('change', function() {

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

The processmonth.php page

$therapistWhere = null;
$params = [':client_id' => $client->id];

if ($therapistId = (int)($_GET['therapist'] ?? 0)) {
    $params[':therapist_id'] = $therapistId;
    $therapistWhere = "AND tbl_therapist.therapist_id = :therapist_id";

$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=3
AND DATE_FORMAT(tbl_session.session_date, "%b") = '$yourValue'
    ORDER BY session_date DESC;
$result = $db->query($sql);

$stmt = $db->prepare($sql);
$rows = $stmt->fetchAll(PDO::FETCH_OBJ);
foreach($rows as $therapist) {
    echo <<< HTML
            <td><?= $row->DATE; ?></td>
         <td><?= $row->TIME; ?></td>
         <td><?= $row->TYPE; ?></td>
         <td><?= $row->THERAPIST; ?></td>
         <td><?= $row->STATUS; ?></td>
And the HTML
 <div id="results">
   <table class="topics" style="width:100%">
          <!--col style="width: 10%;"-->
      <!--col style="width: 0%;"-->
      <col style="width: 35%;">
      <col style="width: 15%;">
      <col style="width: 15%;">
      <col style="width: 20%;">
      <col style="width: 15%;">
    <?php while ($row = $result->fetch(PDO::FETCH_OBJ)): ?>
            <!--td><input type="checkbox"></td-->
         <!--td><!?= $row->ID; ?></td-->
            <td><?= $row->DATE; ?></td>
         <td><?= $row->TIME; ?></td>
         <td><?= $row->TYPE; ?></td>
         <td><?= $row->THERAPIST; ?></td>
         <td><?= $row->STATUS; ?></td>
    <?php endwhile; ?>
Missing something. As it is not filtering...
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros