Wednesday, September 28, 2022
HomePHPFind out how to get Gross sales studies from the database utilizing...

Find out how to get Gross sales studies from the database utilizing PHP- PHPGurukul


<?php

error_reporting(0);

require_once(“config.php”);

?>

<!DOCTYPE html>

<html lang=“en”>

<head>

<meta httpequiv=“content-type” content material=“textual content/html; charset=UTF-8”>

<meta charset=“utf-8”>

<title>PHP GURUKUL | DEMO</title>

<meta title=“generator” content material=“Bootply” />

<meta title=“viewport” content material=“width=device-width, initial-scale=1, maximum-scale=1”>

<hyperlink href=“https://phpgurukul.com/how-to-get-sales-reports-from-the-database-using-php/css/bootstrap.min.css” rel=“stylesheet”>

<![if lt IE 9]>

<script src=“//html5shim.googlecode.com/svn/trunk/html5.js”></script>

<![endif]>

<hyperlink href=“css/kinds.css” rel=“stylesheet”>  

</head>

<physique>

<nav class=“navbar navbar-default navbar-fixed-top” position=“navigation”>

<div class=“navbar-header”>

<h4 model=“padding-left: 100px;padding-top: 20px;”>PHP GURUKUL | Programming Weblog</h4>

</div>

</nav>

<div class=“container-fluid”>

  <!heart>

  <div class=“col-sm-8”>

    <div class=“row”>

      <div class=“col-xs-12”>

        <h3 model=“padding-left: 100px;”>How to get gross sales report from database between two dates in php and MySQL</h3>

<hr >

<type title=“bwdatesdata” motion=“” technique=“submit” motion=“”>

  <desk width=“100%” peak=“117”  border=“0”>

<tr>

    <th width=“27%” peak=“63” scope=“row”>From Date :</th>

    <td width=“73%”>

<enter kind=“date” title=“fdate” class=“form-control” id=“fdate”>

     </td>

  </tr>

 

  <tr>

    <th width=“27%” peak=“63” scope=“row”>To Date :</th>

    <td width=“73%”>

     <enter kind=“date” title=“tdate” class=“form-control” id=“tdate”></td>

  </tr>

  <tr>

    <th width=“27%” peak=“63” scope=“row”>Request Kind :</th>

    <td width=“73%”>

         <enter kind=“radio” title=“requesttype” worth=“mtwise” checked=“true”>Month clever

          <enter kind=“radio” title=“requesttype” worth=“yrwise”>Yr clever</td>

  </tr>

<tr>

    <th width=“27%” peak=“63” scope=“row”></th>

    <td width=“73%”>

     <button class=“btn-primary btn” kind=“submit” title=“submit”>Submit</button>

  </tr>

</desk>

     </type>

      </div>

    </div>

    <hr>

      <div class=“row”>

      <div class=“col-xs-12”>

       <?php

       if(isset($_POST[‘submit’]))

{

$fdate=$_POST[‘fdate’];

$tdate=$_POST[‘tdate’];

$rtype=$_POST[‘requesttype’];

 

?>

<?php if($rtype==‘mtwise’){

$month1=strtotime($fdate);

$month2=strtotime($tdate);

$m1=date(“F”,$month1);

$m2=date(“F”,$month2);

$y1=date(“Y”,$month1);

$y2=date(“Y”,$month2);

    ?>

        <h4 class=“header-title m-t-0 m-b-30”>Gross sales Report Month Sensible</h4>

<h4 align=“heart” model=“shade:blue”>Gross sales Report  from <?php echo $m1.“-“.$y1;?> to <?php echo $m2.“-“.$y2;?></h4>

<hr >

<div class=“row”>

<desk class=“desk table-bordered” width=“100%”  border=“0” model=“padding-left:40px”>

<thead>

<tr>

<th>S.NO</th>

<th>Month / Yr </th>

<th>Gross sales</th>

</tr>

</thead>

<?php

$ret=mysqli_query($con,“choose month(OrderDate) as lmonth,12 months(OrderDate) as lyear,

    tblproduct.SellingPrice,tblorder.Amount from tblorder

    be a part of tblproduct on tblproduct.ID=tblorder.ProductID

    the place date(tblorder.OrderDate) between ‘$fdate’ and ‘$tdate’

    group by lmonth,lyear “);

$num=mysqli_num_rows($ret);

if($num>0){

$cnt=1;

whereas ($row=mysqli_fetch_array($ret)) {

 

?>

<tbody>

<tr>

<td><?php echo $cnt;?></td>

<td><?php  echo $row[‘lmonth’].“/”.$row[‘lyear’];?></td>

<td><?php  echo $whole=$row[‘SellingPrice’]*$row[‘Quantity’];?></td>

</tr>

<?php

$ftotal+=$whole;

$cnt++;

}?>

<tr>

<td colspan=“2” align=“heart”>Whole </td>

<td><?php  echo $ftotal;?></td>

</tr>            

</tbody>

</desk>

<?php } } else {

$year1=strtotime($fdate);

$year2=strtotime($tdate);

$y1=date(“Y”,$year1);

$y2=date(“Y”,$year2);

?>

<h4 class=“header-title m-t-0 m-b-30”>Gross sales Report Yr Sensible</h4>

<h4 align=“heart” model=“shade:blue”>Gross sales Report  from <?php echo $y1;?> to <?php echo $y2;?></h4>

<hr >

<div class=“row”>

<desk class=“desk table-bordered” width=“100%”  border=“0” model=“padding-left:40px”>

<thead>

<tr>

<th>S.NO</th>

<th>Yr </th>

<th>Gross sales</th>

</tr>

</thead>

<?php

$ret=mysqli_query($con,“choose month(OrderDate) as lmonth,12 months(OrderDate) as lyear,

    tblproduct.SellingPrice,tblorder.Amount from tblorder

    be a part of tblproduct on tblproduct.ID=tblorder.ProductID

    the place date(tblorder.OrderDate) between ‘$fdate’ and ‘$tdate’

    group by lyear “);

$num=mysqli_num_rows($ret);

if($num>0){

$cnt=1;

whereas ($row=mysqli_fetch_array($ret)) {

 

?>

<tbody>

<tr>

<td><?php echo $cnt;?></td>

<td><?php  echo $row[‘lyear’];?></td>

<td><?php  echo $whole=$row[‘SellingPrice’]*$row[‘Quantity’];?></td>

</tr>

<?php

$ftotal+=$whole;

$cnt++;

}?>

<tr>

<td colspan=“2” align=“heart”>Whole </td>

<td><?php  echo $ftotal;?></td>

</tr>            

</tbody>

</desk>  <?php } } }?>  

</div>

      </div>

    </div>  

  </div><!/heart>

  <hr>

</div><!/containerfluid>

<! script references >

<script src=“//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js”></script>

<script src=“js/bootstrap.min.js”></script>

</physique>

</html>

 

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments