Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $dbHost = 'localhost';
- $dbUsername = 'root';
- $dbPassword = '';
- $dbName = 'penyatakewangan';
- //Connect with the database
- $db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);
- //Display error if failed to connect
- if ($db->connect_errno) {
- printf("Connect failed: %s\n", $db->connect_error);
- exit();
- }
- $sql = "SELECT * FROM akaun where jenis = 1";
- $resultdebit = mysqli_query($db,$sql);
- $resultdebit2 = mysqli_query($db,$sql);
- $sql = "SELECT * FROM akaun where jenis = 2";
- $resultkredit = mysqli_query($db,$sql);
- $resultkredit2 = mysqli_query($db,$sql);
- ?>
- <!doctype html>
- <html lang="en">
- <head>
- <!-- Required meta tags -->
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <!-- Bootstrap CSS -->
- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
- <title>Hello, world!</title>
- </head>
- <body>
- <main class="container">
- <h1>Penyata Kewangan</h1>
- <table class="table">
- <thead class="thead-dark">
- <tr>
- <th style="width: 5%">#</th>
- <th style="width: 25%">Tajuk</th>
- <th style="width: 10%">Debit</th>
- <th style="width: 5%">#</th>
- <th style="width: 25%">Tajuk</th>
- <th style="width: 10%">Kredit</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <th ><?php $v1 =1; echo $v1;?></th>
- <td><?php while($debit = mysqli_fetch_assoc($resultdebit)){?> <?=$debit['tajuk']?></br> <?php $v1++;}?></td>
- <td><?php $jumdebit = 0; while($debitt = mysqli_fetch_assoc($resultdebit2)){?> <?=$debitt['jumlah']?></br> <?php $jumdebit+=$debitt['jumlah']; }?></td>
- <th ><?php $v2 =1; echo $v2;?></th>
- <td><?php while($kredit = mysqli_fetch_assoc($resultkredit)){?> <?=$kredit['tajuk']?></br> <?php $v2++;}?></td>
- <td><?php $jumkredit = 0; while($kreditt = mysqli_fetch_assoc($resultkredit2)){?> <?=$kreditt['jumlah']?></br> <?php $jumkredit+=$kreditt['jumlah']; }?></td>
- </tr>
- <tr>
- <td colspan="1"></td>
- <td >Untung Kasar</td>
- <td ><?=$jumdebit?></td>
- <td colspan="1"></td>
- <td >Rugi Kasar</td>
- <td ><?=$jumkredit?></td>
- </tr>
- <tr>
- <?php
- if($jumdebit > $jumkredit){
- $untung = $jumdebit - $jumkredit;
- $inUntung =$untung ;
- $indRugi = '-';
- }else {
- $rugi = $jumkredit - $jumdebit;
- $inUntung ='' ;
- $indRugi = $rugi;
- }
- ?>
- <td colspan="1"></td>
- <td >Untung Bersih</td>
- <td ><?=$inUntung?></td>
- <td colspan="1"></td>
- <td >Rugi Bersih</td>
- <td ><?=$indRugi?></td>
- </tr>
- </tbody>
- </table>
- </main>
- <!-- Optional JavaScript -->
- <!-- jQuery first, then Popper.js, then Bootstrap JS -->
- <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
- <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>
- <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement