How to show all data when post data is empty mySQL

Viewed 47

I have a query that runs when a user submits a start and end date. I would like the table to populate first if the form has not been submitted. If user goes to /records.php it should show all records. Then user can filter with the form to the between dates he wants. Right now the filter works fine but when a user visits the page no data loads.

if(!isset($_GET['datemin'])){

$query_date = date("Y/m/d");

      // First day of the month.
$mindate = date("M d, Y", strtotime("first day of previous month"));

      // Last day of the month.
$maxdate = date('M d, Y', strtotime("last day of previous month"));
}else{


$date = new DateTime($_GET['datemin']);
$mindate = $date->format('M d, Y');

$date = new DateTime($_GET['datemax']);
$maxdate = $date->format('M d, Y');

}

SELECT
*
FROM records RQ
AND Sold_On BETWEEN "'.$mindate.'" AND "'.$maxdate.'"

How do I go about getting this to load all data for records without using the form? Then have them filter as they see fit? Any direction on how I would search what I am looking for is also helpful so I can read up on this.

The above script currently grabs last month data. I would like it to show ALL data though. Could be 4 months or 4 years old.

0 Answers
Related