Monday, 22 July 2013

Get monthly (month wise) data or year wise data from database

Output
Fetch Data Year Wise:

<?php
$cc=mysql_connect("127.0.0.1","root","");
$t=mysql_select_db("maha",$cc);
$det=mysql_query("select * from freelisting where last_update > DATE_SUB(NOW(),INTERVAL 1 YEAR) order by fid ");
while($r=mysql_fetch_array($det))
{
$n=$r['person'];
$c=$r['city'];
$id=$r['fid'];
$rtt=$r['last_update'];
}
?>

Fetch Data Month Wise:

$det=mysql_query("select * from freelisting where last_update > DATE_SUB(NOW(),INTERVAL 1 month) order by fid "); 

Fetch Data Week Wise:

$det=mysql_query("select * from freelisting where last_update > DATE_SUB(NOW(),INTERVAL 1 week) order by fid "); 

Fetch Data Day Wise:

$det=mysql_query("select * from freelisting where last_update > DATE_SUB(NOW(),INTERVAL 1 day) order by fid ");




No comments:

Post a Comment