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