From ali, 6 Years ago, written in Plain Text.
Embed
  1. <?php
  2.  
  3. include("includes/db.php");
  4. $query=mysqli_query($con,"SELECT * from vouchers ");
  5. $rowcount=mysqli_num_rows($query);
  6.  
  7. ?>
  8. <h3>Count of Voucher Values </h3>
  9. <?php
  10.  
  11. $sum=0;
  12. $hun=0;
  13. $twohun=0;
  14. $threehun=0;
  15. $thous=0;
  16. for($i=1;$i<=$rowcount;$i++)
  17. {
  18.  
  19.         $row=mysqli_fetch_array($query);
  20.         $sum += $row["v_value"];         // calulating the sum of voucher value
  21.  
  22.  
  23.         if($row["v_value"]=="100")      // for calulating total number 100 values if function
  24.         {
  25.             $hun++;                     //adding count of 100
  26.         }
  27.  
  28.         if ($row["v_value"]=="300")     // for calulating total number 300 values if function
  29.         {
  30.             $twohun++;                  //adding count of 300  
  31.         }
  32.  
  33.         if ($row["v_value"]=="500")     // for calulating total number 500 values if function
  34.         {
  35.             $threehun++;                    //adding count of 500  
  36.         }
  37.  
  38.         if ($row["v_value"]=="1000")    // for calulating total number 1000 values if function
  39.         {
  40.             $thous++;                   //adding count of 1000  
  41.         }
  42. ?>
  43.  
  44. <?php
  45. }
  46. ?>
  47.  
  48. </table>
  49. <table border="1" align="center" id="example" class="display" style="width:20%">
  50.     <tr>
  51.         <td>100</td>
  52.         <td>300</td>
  53.         <td>500</td>
  54. <td>500</td>
  55.         <td>1000</td>
  56.     </tr>
  57.     <tr>
  58.         <td><?php echo $hun ?></td>     <?php // showing value of 100?>
  59.         <td><?php echo $twohun ?></td>  <?php // showing value of 300?>
  60.         <td><?php echo $threehun ?></td> <?php // showing value of 500?>
  61.         <td><?php echo $thous ?></td>   <?php // showing value of 1000?>
  62.     </tr>
  63. </table>
  64. <?php
  65.  
  66. $query=mysqli_query($con,"select * from purchased");
  67. $rowcount=mysqli_num_rows($query);
  68. $hun=0;
  69. $fivhun=0;
  70. $threehun=0;
  71. $thous=0;
  72. $z100=0;
  73. $z300=0;
  74. $z500=0;
  75. $z1000=0;
  76. $t100=0;
  77. $t300=0;
  78. $t500=0;
  79. $t1000=0;
  80. $j100=0;
  81. $j300=0;
  82. $j500=0;
  83. $j1000=0;
  84.  
  85.  
  86. ?>
  87. <h3>Count of vouchers sold</h3>
  88. <table border="1" align="center" id="example" class="display" style="width:50% ;text-align: center;" >
  89. <tr>
  90. <?php
  91.  
  92. for($i=1;$i<=$rowcount;$i++)
  93. {
  94. $row=mysqli_fetch_array($query);
  95.         if($row["item_name"]=="Zong-100"  )
  96.         {
  97.            $z100+= $row["quantity"];
  98.         }
  99.  
  100.         $row=mysqli_fetch_array($query);
  101.         if($row["item_name"]=="Zong-300" )
  102.         {
  103.            $z300+= $row["quantity"];
  104.         }
  105.  
  106.         $row=mysqli_fetch_array($query);
  107.         if($row["item_name"]=="Zong-500")
  108.         {
  109.            $z500+= $row["quantity"];
  110.         }
  111.  
  112.         $row=mysqli_fetch_array($query);
  113.         if($row["item_name"]=="Zong-1000" )
  114.         {
  115.            $z1000+= $row["quantity"];
  116.         }
  117.  
  118.         $row=mysqli_fetch_array($query);
  119.         if($row["item_name"]=="Telenor-100"  )
  120.         {
  121.            $t100+= $row["quantity"];
  122.         }
  123.  
  124.         $row=mysqli_fetch_array($query);
  125.         if($row["item_name"]=="Telenor-300" )
  126.         {
  127.            $t300+= $row["quantity"];
  128.         }
  129.  
  130.         $row=mysqli_fetch_array($query);
  131.         if($row["item_name"]=="Telenor-500" )
  132.         {
  133.            $t500+= $row["quantity"];
  134.         }
  135.  
  136.         $row=mysqli_fetch_array($query);
  137.         if($row["item_name"]=="Telenor-1000" )
  138.         {
  139.            $t1000+= $row["quantity"];
  140.         }
  141.  
  142.         $row=mysqli_fetch_array($query);
  143.         if($row["item_name"]=="Jazz-100" )
  144.         {
  145.            $j100+= $row["quantity"];
  146. }
  147.  
  148.         $row=mysqli_fetch_array($query);
  149.         if($row["item_name"]=="Jazz-300" )
  150.         {
  151.            $j300+= $row["quantity"];
  152.         }
  153.  
  154.         $row=mysqli_fetch_array($query);
  155.         if($row["item_name"]=="Jazz-500" )
  156.         {
  157.            $j500+= $row["quantity"];
  158.         }
  159.  
  160.         $row=mysqli_fetch_array($query);
  161.         if($row["item_name"]=="Jazz-1000" )
  162.         {
  163.            $j1000+= $row["quantity"];
  164.         }
  165.  
  166.  
  167.  
  168. ?>
  169. <?php
  170. }
  171.  
  172. ?>
  173. <tr>
  174.         <td>Z-100</td>
  175.         <td>Z-300</td>
  176.         <td>Z-500</td>
  177.         <td>Z-1000</td>
  178.         <td>T-100</td>
  179.         <td>T-300</td>
  180.         <td>T-500</td>
  181.         <td>T-1000</td>
  182.         <td>J-100</td>
  183.         <td>J-300</td>
  184.         <td>J-500</td>
  185.         <td>J-1000</td>
  186.     </tr>
  187.     <tr>
  188.         <td><?php echo $z100; ?></td>   <?php // showing value of 100?>
  189.         <td><?php echo $z300; ?></td>  <?php // showing value of 300?>
  190.         <td><?php echo $z500; ?></td> <?php // showing value of 500?>
  191.         <td><?php echo $z1000; ?></td>   <?php // showing value of 1000?>
  192.  
  193.         <td><?php echo $t100; ?></td>   <?php // showing value of 100?>
  194.         <td><?php echo $t300; ?></td>  <?php // showing value of 300?>
  195.         <td><?php echo $t500; ?></td> <?php // showing value of 500?>
  196.         <td><?php echo $t1000; ?></td>   <?php // showing value of 1000?>
  197.  <td><?php echo $t100; ?></td>   <?php // showing value of 100?>
  198.         <td><?php echo $t300; ?></td>  <?php // showing value of 300?>
  199.         <td><?php echo $t500; ?></td> <?php // showing value of 500?>
  200.         <td><?php echo $t1000; ?></td>   <?php // showing value of 1000?>
  201.     </tr>
  202.  
  203. </table>
  204.  
  205. <script>
  206. $(document).ready(function() {
  207.     $('#example').DataTable({"lengthMenu": [[100, 200, 300, 400], [100, 200, 300, 400]]});
  208. } );
  209. </script>