daily pastebin goal
8%
SHARE
TWEET

penyatakewangan

a guest Apr 27th, 2018 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $dbHost = 'localhost';
  4. $dbUsername = 'root';
  5. $dbPassword = '';
  6. $dbName = 'penyatakewangan';
  7. //Connect with the database
  8. $db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);
  9.  
  10. //Display error if failed to connect
  11. if ($db->connect_errno) {
  12.     printf("Connect failed: %s\n", $db->connect_error);
  13.     exit();
  14. }
  15.  
  16. $sql = "SELECT * FROM akaun where jenis = 1";
  17. $resultdebit = mysqli_query($db,$sql);
  18. $resultdebit2 = mysqli_query($db,$sql);
  19.  
  20. $sql = "SELECT * FROM akaun where jenis = 2";
  21. $resultkredit = mysqli_query($db,$sql);
  22. $resultkredit2 = mysqli_query($db,$sql);
  23. ?>
  24. <!doctype html>
  25. <html lang="en">
  26.   <head>
  27.     <!-- Required meta tags -->
  28.     <meta charset="utf-8">
  29.     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  30.  
  31.     <!-- Bootstrap CSS -->
  32.     <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
  33.  
  34.     <title>Hello, world!</title>
  35.   </head>
  36.   <body>
  37.   <main class="container">
  38.     <h1>Penyata Kewangan</h1>
  39.     <table class="table">
  40.     <thead class="thead-dark">
  41.         <tr>
  42.         <th style="width: 5%">#</th>
  43.         <th style="width: 25%">Tajuk</th>
  44.         <th style="width: 10%">Debit</th>
  45.  
  46.         <th style="width: 5%">#</th>
  47.         <th style="width: 25%">Tajuk</th>
  48.         <th style="width: 10%">Kredit</th>
  49.         </tr>
  50.     </thead>
  51.     <tbody>
  52.         <tr>
  53.         <th ><?php $v1 =1; echo $v1;?></th>
  54.            
  55.         <td><?php while($debit = mysqli_fetch_assoc($resultdebit)){?> <?=$debit['tajuk']?></br> <?php $v1++;}?></td>
  56.         <td><?php $jumdebit = 0; while($debitt = mysqli_fetch_assoc($resultdebit2)){?> <?=$debitt['jumlah']?></br> <?php $jumdebit+=$debitt['jumlah']; }?></td>
  57.          
  58.         <th ><?php $v2 =1; echo $v2;?></th>
  59.         <td><?php while($kredit = mysqli_fetch_assoc($resultkredit)){?> <?=$kredit['tajuk']?></br> <?php $v2++;}?></td>
  60.         <td><?php $jumkredit = 0; while($kreditt = mysqli_fetch_assoc($resultkredit2)){?> <?=$kreditt['jumlah']?></br> <?php $jumkredit+=$kreditt['jumlah']; }?></td>
  61.        
  62.         </tr>
  63.         <tr>
  64.         <td colspan="1"></td>
  65.         <td >Untung Kasar</td>
  66.         <td ><?=$jumdebit?></td>
  67.  
  68.         <td colspan="1"></td>
  69.         <td >Rugi Kasar</td>
  70.         <td ><?=$jumkredit?></td>
  71.         </tr>
  72.         <tr>
  73.         <?php
  74.         if($jumdebit > $jumkredit){
  75.              $untung = $jumdebit - $jumkredit;
  76.              $inUntung =$untung ;
  77.              $indRugi = '-';
  78.         }else  {
  79.             $rugi = $jumkredit - $jumdebit;
  80.             $inUntung ='' ;
  81.             $indRugi = $rugi;
  82.         }
  83.         ?>
  84.         <td colspan="1"></td>
  85.         <td >Untung Bersih</td>
  86.         <td ><?=$inUntung?></td>
  87.  
  88.         <td colspan="1"></td>
  89.         <td >Rugi Bersih</td>
  90.         <td ><?=$indRugi?></td>
  91.         </tr>
  92.     </tbody>
  93.     </table>
  94.  
  95.  
  96.   </main>
  97.     <!-- Optional JavaScript -->
  98.     <!-- jQuery first, then Popper.js, then Bootstrap JS -->
  99.     <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
  100.     <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
  101.     <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
  102.   </body>
  103. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top