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>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s