Sort by today, this week, this month

$by=trim($_REQUEST[‘by’]);
if($by==’today’) { $cond.=” and DATE(activity_crtd)='”.date(“Y-m-d”).”‘”; }
if($by==’week’) { $cond.=” and YEARWEEK(activity_crtd) = YEARWEEK(‘”.date(“Y-m-d”).”‘) “; }
if($by==’month’) { $cond.=” and YEAR(activity_crtd) = ‘”.date(“Y”).”‘ and MONTH(activity_crtd) = ‘”.date(“m”).”‘ “; }

$qry = “select * from `table_name` where status=’Active’ “.$cond
    
<select onchange=”window.location=’my_profile.php?by=’+this.value” name=””>
<option value=”all”>All </option>
<option value=”today”>Today</option>
<option value=”week”>This Week</option>
<option value=”month”>This Month </option>
</select>