Maggie Ackermann
Maggie Ackermann

Reputation: 253

PHP code for Current Date filter with Mysql

I have a table with numerous colums the SQL query I want to draw information from that table and just show information for the current month up to the current date

This is what I currently have

 $query = "SELECT * FROM lbs_trace_etrack WHERE lbs_client='$slcustom1' AND WHERE 
 MONTH(STR_TO_DATE(lbs_date, '%Y/%m/%d')) = MONTH(NOW()) "

It is not showing any records for this month at all

Thank you for assistance

Upvotes: 0

Views: 312

Answers (1)

Maykonn
Maykonn

Reputation: 2928

Your query is wrong, had two WHEREs words, correct for:

$query = "
    SELECT 
        * 
    FROM 
        lbs_trace_etrack 
    WHERE 
        lbs_client = '".$slcustom1."'
    AND MONTH (lbs_date) = MONTH (NOW())";

Ever enable errors on PHP to see errors:

ini_set("error_reporting", E_ALL);
ini_set("display_errors", true);

Upvotes: 4

Related Questions