my database table looks like below
| id | user_name | address | contact | date | |----|-----------|---------|---------|----------| | 1 | john | NY
This is how you can achieve:
$qs = ""; if( is_array($condition) && count($condition) > 0 ): foreach( $condition as $_k => $_v ) { $qs .= "and $_k = {$_v} "; } endif; 'SELECT * FROM '.$table.' WHERE `date` BETWEEN DATE_SUB(NOW(), INTERVAL 15 DAY) AND NOW() '.$qs