Gary
Gary

Reputation: 29

Latest by current date

I need help with an query. It is to list only 3 dog shows, by the row postal_date. However, I do not want any results that are past the current date.

I have them listed but some do show past the current date.

<?php
    $query = "SELECT shows.*, judges.* FROM `shows` 
    INNER JOIN `judges` ON shows.judge_id = judges.judge_id
    ORDER BY shows.postal_close DESC
    LIMIT 3";

    $select_all_shows_query = mysqli_query($connection,$query);
    while($row = mysqli_fetch_assoc($select_all_shows_query)) {

      $show_id      = $row['show_id'];
      $show_title   = $row['show_title'];
      $postal_close         = date('d F Y', strtotime($row['postal_close']));
      $show_image   = $row['show_image'];
      $judge_name2  = $row['judge_name2'];
      $judge_id         = $row['judge_id'];

    ?>

Upvotes: 1

Views: 35

Answers (1)

suvojit_007
suvojit_007

Reputation: 1728

    $query = "SELECT shows.*, judges.* FROM `shows` 
INNER JOIN `judges` ON shows.judge_id = judges.judge_id 
WHERE DATE(shows.postal_close) >=  CURDATE()
 ORDER BY shows.postal_close DESC LIMIT 3";

Upvotes: 2

Related Questions