This is one of my first attempts at querying the WordPress database for data, and some my first PHP code ever, so please bear that in mind when commenting.
It is supposed find data between two dates, and show it as HTML in a
for each loop. How can this be made better? What is the correct way to query a WordPress database?
<?php require_once('wp-load.php'); $sd = date('Y-m-d', strtotime(($startdate = filter_input(INPUT_GET, 'startdate')))); $ed = date('Y-m-d', strtotime(($enddate = filter_input(INPUT_GET, 'enddate')))); $query = $wpdb->prepare("SELECT FirstName, LastName, FROM WHEN HireDate BETWEEN '%s' and '%s'" $sd, $ed); echo $query; $results = $wpdb->get_results( $query ); ?>