<?php
ob_start();
require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include('includes/function.php');

$maindb = "rank";
$formname = "Rank List";
$file = "ranklst.php";

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$myyear = $_SESSION[$myyear];
mysqli_select_db($conn, $zdb);

if (isset($_POST["view"])) {
    $code = $_POST[code];
    $name = $_POST[name];

    $namecond = "";

    if (!empty($name)) {
        $namecond = " AND `name` LIKE '%$name%' ";
    }

    $getpmain = mysqli_query($conn, "SELECT * FROM `$maindb` WHERE `name`!='' $namecond ")or die(mysqli_error($conn));
    $getno = mysqli_num_rows($getpmain);


    include("includes/linkshead.php");
    ?>
    <!--<script src="MyScript/item.js" type="text/javascript"></script>-->
    </head>
    <body>
        <div class="container">
            <div class="row">
                <div class="col-lg-6">
                    <?php
                    require("includes/dbconnect.php");
                    $comp = mysqli_query($conn, "SELECT * FROM `company`") or die(mysql_errno());
                    $zcomp = mysqli_fetch_assoc($comp);
                    echo "<font size='4px' ><b>$zcomp[name]</font></b></font><br />";
                    echo "<font size='2px' ><b> $zcomp[address]. </b></font><br />";
//              echo "<b><font >$formname &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font size='3px'>Date : ".date("M-d-Y") . "</b><br />";
                    echo "<b>" . "Total  - $getno</b><br />";
//              echo "<br />";
                    ?>
                </div>

                <div class="col-lg-6">
                    <label class="label-control marg">Date - </label>
                    <label class="label-control marg"><?php Echo Date("d-m-Y"); ?></label>
                </div>
                <div class="col-lg-6">
                    <label class="label-control marg">Print - </label>
                    <label class="label-control marg"><?php Echo $formname; ?></label>
                    <div class="col-lg-1 pull-right" >
                        <button id='cancel' type="reset" class="btn btn-primary" style="background-color:red;" onClick="window.location.href = '<?php echo $file; ?>'"> 
                            Go Back
                        </button>
                    </div>
                </div>

            </div>
            <div class="row">
                <div class="col-lg-12 pad">
                    <table class="table table-condensed table-hover">
                        <tr  style="background-color: #05B2EA">
                            <th>Sr</th>
                            <th>Code</th>
                            <th>Name</th>
                        </tr>
                        <?php
                        $ctr = 1;
                        while ($pmain = mysqli_fetch_array($getpmain)) {

                            Echo "<tr>";
                            Echo "<td>$ctr</td>";
                            Echo "<td>$pmain[code]</td>";
                            Echo "<td>$pmain[name]</td>";
                            Echo "</tr>";
                            $ctr++;
                        }
                        ?>
                    </table>
                </div>
            </div>
        </div>

        <?php include("includes/linksfoot.php"); ?>
    </body>
    </html>
<? } ?>
