Posted inProgramming / Mysql / Mysqli / php

PHP GET Today Yesterday Last-7-Days This-Month-Last-Month This-Year Last-Year,All-Time

PHP GET Today Yesterday Last-7-Days This-Month-Last-Month This-Year Last-Year,All-Time

Welcome to the In Pakainfo.com website! You will Step By Step learn web programming, easy and very fun. This website allmost provides you with a complete web programming tutorial presented in an easy-to-follow manner. Each web programming tutorial has all the practical examples with web programming script and screenshots available.For

Select records from today, this week, this month php mysql

";
echo $today = date('Y-m-d');
echo $datseven=date('Y-m-d', strtotime('-7 days'));
echo $datyesterday=date('Y-m-d', strtotime('-1 days'));
echo $thismonth=date('m');
echo $lastmonth=date('m', strtotime(date('Y-m')." -1 month"));
echo $thisyear=date('Y');
echo $lastyear=date("Y",strtotime("-1 year"));
echo "

“;
?>

HTML Part

php Part : Query check function

= '$datseven' and DATE(suptotal.sdate) >= '$datseven' ORDER BY users.name ASC";
		}
		if($sdate==1)
		{
				$query = "select DISTINCT (users.id),suptotal.total,users.user_bm_percent,users.user_type,users.name,users.user_on_percent,users.status from users INNER JOIN subbig ON users.id=subbig.user_id INNER JOIN suptotal ON users.id=suptotal.user_id where DATE(subbig.date) = '$datyesterday' and DATE(suptotal.sdate) = '$datyesterday' ORDER BY users.name ASC";
				 
		}
		if($sdate==30)
		{
				$query = "select DISTINCT (users.id),suptotal.total,users.user_bm_percent,users.user_type,users.name,users.user_on_percent,users.status from users INNER JOIN subbig ON users.id=subbig.user_id INNER JOIN suptotal ON users.id=suptotal.user_id where MONTH(subbig.date) = '$thismonth' and MONTH(suptotal.sdate) = '$thismonth' ORDER BY users.name ASC";
				
		}
		if($sdate==31)
		{
				$query = "select DISTINCT (users.id),suptotal.total,users.user_bm_percent,users.user_type,users.name,users.user_on_percent,users.status from users INNER JOIN subbig ON users.id=subbig.user_id INNER JOIN suptotal ON users.id=suptotal.user_id where MONTH(subbig.date) = '$lastmonth' and MONTH(suptotal.sdate) ='$lastmonth' ORDER BY users.name ASC";
				
		}
		if($sdate==365)
		{
				$query = "select DISTINCT (users.id),suptotal.total,users.user_bm_percent,users.user_type,users.name,users.user_on_percent,users.status from users INNER JOIN subbig ON users.id=subbig.user_id INNER JOIN suptotal ON users.id=suptotal.user_id where YEAR(subbig.date) = '$thisyear' and YEAR(suptotal.sdate) ='$thisyear' ORDER BY users.name ASC";
				
		}
		if($sdate==366)
		{
				$query = "select DISTINCT (users.id),suptotal.total,users.user_bm_percent,users.user_type,users.name,users.user_on_percent,users.status from users INNER JOIN subbig ON users.id=subbig.user_id INNER JOIN suptotal ON users.id=suptotal.user_id where YEAR(subbig.date) = '$lastyear' and YEAR(suptotal.sdate) ='$lastyear' ORDER BY users.name ASC";
				
		}
		if($sdate==0)
		{
				$query = "select DISTINCT (users.id),suptotal.total,users.user_bm_percent,users.user_type,users.name,users.user_on_percent,users.status from users INNER JOIN subbig ON users.id=subbig.user_id 
				INNER JOIN suptotal ON users.id=suptotal.user_id where DATE(subbig.date) = '$today' and DATE(suptotal.sdate) = '$today' ORDER BY users.name ASC";
		}
		if($sdate==9)
		{
				$query = "select DISTINCT (users.id),SUM(suptotal.total) as total,users.user_bm_percent,users.user_type,users.name,users.user_on_percent,users.status from users INNER JOIN subbig ON users.id=subbig.user_id 
				INNER JOIN suptotal ON users.id=suptotal.user_id GROUP BY users.id ORDER BY users.name ASC";
		}
		echo "
";
		print_r($query);
		echo "

";
}
?>

Join Query with Date Format Yesterday

$query = “select DISTINCT (users.id),suptotal.total,users.user_bm_percent,users.user_type,users.name,users.user_on_percent,users.status from users INNER JOIN subbig ON users.id=subbig.user_id INNER JOIN suptotal ON users.id=suptotal.user_id where DATE(subbig.date) = ‘$datyesterday’ and DATE(suptotal.sdate) = ‘$datyesterday’ ORDER BY users.name ASC”;

Example

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype