<style>
    @media print{
        .hide {
            display:none;
        }
    }
</style>



<script>
    function printme(){
	    window.print();
    }
</script>
<form method="post" action="">
<select class="hide" name="section">
    <option value="">--Select Section--</option>
    <?php $section = $db->getRows("select * from section order by name");
        foreach($section as $sec){?>
        <option value="<?php echo $sec["name"]; ?>"><?php echo $sec["name"]; ?></option>
        <?php } ?>
</select>
<button type="submit" class="hide">Search</button>
<button onclick="printme()" class="hide">Print</button>
</form>

<?php
    $id = $_GET['id'];
    $class = $_GET['class'];

    $wheresection = "";
    if(isset($_POST["section"]) && trim($_POST['section'])!=''){
        $wheresection = " section='$_POST[section]' and ";
    } else {
        if($_GET['section']!=""){
            $wheresection = " section='$_GET[section]' and ";
        }
    }

	$paper = $db->getRow("SELECT * FROM omr_paper WHERE session='".$_SESSION["admin"]["session"]."' and id='$id' ");

    $subomr = $db->getVal("select sub_omr from subject where id='$paper[subject]' ");

    if(count($paper) > 0){

    $allquestions = $db->getRows("select * from omr_question where paper='$id' ");

    $allstudent = $db->getRows("select * from student where class='$class' and $wheresection session='".$_SESSION['admin']['session']."' and status=1 ");
    foreach($allstudent as $stu){
?>
<div class="mydiv">
    <div style="background:black;width:20px;height:20px;float:left;"></div>
    <div style="background:black;width:20px;height:20px;float:right;"></div>
    <br><br>
    <div class="tab-content">

        <div style="width:100%;">

            <div style="width:100%;float:left;">
                <table cellspacing="0" style="width:100%;color:#d11d53;text-align:center;border-color:#d11d53" border="1">
                    <tr>
                        <td style="background:pink;color:black;font-weight:600">Class</td>
                        <td style="background:pink;color:black;font-weight:600">Student's Name</td>
                        <td style="background:pink;color:black;font-weight:600">Subject</td>
                        <td style="background:pink;color:black;font-weight:600;width:100px;">Roll No.</td>
                    </tr>
                    <tr>
                        <!--<td style="height:25px;font-weight:600;"><?php echo $stu['omr']; ?></td>-->
                        <!--<td style="height:25px;font-weight:600;"><?php echo $stu['name']; ?></td>-->
                        <!--<td style="height:25px;font-weight:600;"><?php echo $subomr;?></td>-->
                        <!--<td style="height:25px;font-weight:600;"><?php echo $stu['fincome']; ?></td>-->
                        <td style="height:25px;font-weight:600;"><?php //echo $stu['omr']; ?></td>
                        <td style="height:25px;font-weight:600;"><?php //echo $stu['name']; ?></td>
                        <td style="height:25px;font-weight:600;"><?php //echo $subomr;?></td>
                        <td style="height:25px;font-weight:600;"><?php //echo $stu['fincome']; ?></td>
                    </tr>
                </table>
            </div>

        </div>

    </div>
    <div style="width:950px;color:transparent">.</div>

    <div style="width:100%;float:left;margin-top:20px;">
        <?php
        $max = count($allquestions);
            if(count($allquestions)>0 ){
                ?>
                <table cellspacing="0" style="color:#d11d53;text-align:center;display:inline-block;float:left;margin-top:0px;width:2%;margin-left:1%;">
                    <?php
                        for($i=1;$i<21;$i++){
                            if($i<=$max){   ?>
                            <tr>
                                <td style="width:20px;font-weight:bold;padding:5px;border:solid 1px;padding-top:10px;padding-bottom:10px;"><?php echo $i; ?></td>
                            </tr>
                            <?php
                            }   }
                    ?>
                </table>

                <table cellspacing="0" style="color:#d11d53;text-align:center;display:inline-block;float:left;margin-top:0px;width:20%;border:solid 1px;margin-left:2%;">
                    <?php
                        for($i=1;$i<21;$i++){
                            if($i<=$max){   ?>
                            <tr>
                                <?php foreach( range('A', 'D') as $ele) {
                                        echo "<td style='font-weight:bold;text-align:center;padding:5px;padding-left:18px;padding-top:10px;padding-bottom:10px;'><p style='border:solid 1px;width:18px;height:18px;border-radius:50%;'>$ele</p></td>";
                                    }
                                ?>
                            </tr>
                            <?php
                            }   }
                    ?>
                </table>

                <table cellspacing="0" style="color:#d11d53;text-align:center;display:inline-block;float:left;margin-top:0px;width:2%;margin-left:1%">
                    <?php
                        for($i=21;$i<41;$i++){
                            if($i<=$max){   ?>
                            <tr>
                                <td style="width:20px;font-weight:bold;padding:5px;border:solid 1px;padding-top:10px;padding-bottom:10px;"><?php echo $i; ?></td>
                            </tr>
                            <?php
                            }   }
                    ?>
                </table>

                <table cellspacing="0" style="color:#d11d53;text-align:center;display:inline-block;float:left;margin-top:0px;width:20%;border:solid 1px;margin-left:2%;">
                    <?php
                        for($i=21;$i<41;$i++){
                            if($i<=$max){   ?>
                            <tr>
                                <?php foreach( range('A', 'D') as $ele) {
                                        echo "<td style='font-weight:bold;text-align:center;padding:5px;padding-left:20px;padding-top:10px;padding-bottom:10px;'><p style='border:solid 1px;width:18px;height:18px;border-radius:50%;'>$ele</p></td>";
                                    }
                                ?>
                            </tr>
                            <?php
                            }   }
                    ?>
                </table>

                    <table cellspacing="0" style="color:#d11d53;text-align:center;display:inline-block;float:left;margin-top:0px;width:2%;margin-left:1%;">
                        <?php
                            for($i=41;$i<61;$i++){
                                if($i<=$max){   ?>
                                <tr>
                                    <td style="width:20px;font-weight:bold;padding:5px;border:solid 1px;padding-top:10px;padding-bottom:10px;"><?php echo $i; ?></td>
                                </tr>
                                <?php
                                }   }
                        ?>
                    </table>

                    <table cellspacing="0" style="color:#d11d53;text-align:center;display:inline-block;float:left;margin-top:0px;width:20%;border:solid 1px;margin-left:2%">
                        <?php
                            for($i=41;$i<61;$i++){
                                if($i<=$max){   ?>
                                <tr>
                                    <?php foreach( range('A', 'D') as $ele) {
                                            echo "<td style='font-weight:bold;text-align:center;padding:5px;padding-left:20px;padding-top:10px;padding-bottom:10px;'><p style='border:solid 1px;width:18px;height:18px;border-radius:50%;'>$ele</p></td>";
                                        }
                                    ?>
                                </tr>
                                <?php
                                }   }
                        ?>
                    </table>

                    <table cellspacing="0" style="color:#d11d53;text-align:center;display:inline-block;float:left;margin-top:0px;width:2%;margin-left:1%;">
                        <?php
                            for($i=61;$i<81;$i++){
                                if($i<=$max){   ?>
                                <tr>
                                    <td style="width:20px;font-weight:bold;padding:5px;border:solid 1px;padding-top:10px;padding-bottom:10px;"><?php echo $i; ?></td>
                                </tr>
                                <?php
                                }   }
                        ?>
                    </table>

                    <table cellspacing="0" style="color:#d11d53;text-align:center;display:inline-block;float:left;margin-top:0px;width:20%;border:solid 1px;margin-left:2%;">
                        <?php
                            for($i=61;$i<81;$i++){
                                if($i<=$max){   ?>
                                <tr>
                                    <?php foreach( range('A', 'D') as $ele) {
                                            echo "<td style='font-weight:bold;text-align:center;padding:5px;padding-left:20px;padding-top:10px;padding-bottom:10px;'><p style='border:solid 1px;width:18px;height:18px;border-radius:50%;'>$ele</p></td>";
                                        }
                                    ?>
                                </tr>
                                <?php
                                }   }
                        ?>
                    </table>

                <?php
                }

        ?>
      </div>

    <div style="background:black;width:20px;height:20px;float:left;bottom:-5px;position:relative;"></div>
    <div style="background:black;width:20px;height:20px;bottom:-5px;position:relative;float:right;"></div>

</div>
<style>
    @media print {
        .mydiv {page-break-after: always;}
    }
</style>

<?php }
    }   ?>









<!--// <style>-->
<!--//     .number-parent {-->
<!--//         width:50px;border-left:solid 1px;border-right:solid 1px;-->
<!--//     }-->

<!--//     .number-div {-->
<!--//         width:20px;height:20px;border:solid 1px;border-color:transparent;text-align:center;margin:2px 10px;display:inline-block;-->
<!--//     }-->

<!--//     .option-div {-->
<!--//         width:20px;height:20px;border-radius:50%;border:solid 1px;text-align:center;margin:2px 22px;display:inline-block;-->
<!--//     }-->
<!--// </style>-->

<!--// <div style="display:inline-block;">-->

    <?php //for($i=1;$i<41;$i++){
        //if($i===1){
    ?>
    <!--<div class="number-parent" style="border-top:solid 1px;">-->
    <!--    <div class="number-div"><?php echo $i; ?></div>-->
    <!--</div>-->
    <?php //} elseif($i===40) { ?>
    <!--<div class="number-parent" style="border-bottom:solid 1px;">-->
    <!--    <div class="number-div"><?php echo $i; ?></div>-->
    <!--</div>-->

    <?php //} else { ?>
    <!--<div class="number-parent">-->
    <!--    <div class="number-div"><?php echo $i; ?></div>-->
    <!--</div>-->

    <?php //}} ?>

<!--</div>-->

<!--<div style="display:inline-block;">-->

    <?php //for($i=1;$i<41;$i++){
        //if($i===1){
    ?>
    <!--<div style="width:280px;border-left:solid 1px;border-top:solid 1px;border-right:solid 1px;">-->
    <!--    <div class="option-div">A</div>-->
    <!--    <div class="option-div">B</div>-->
    <!--    <div class="option-div">C</div>-->
    <!--    <div class="option-div">D</div>-->
    <!--</div>-->
    <?php //} elseif($i===40) { ?>
    <!--<div style="width:280px;border-left:solid 1px;border-bottom:solid 1px;border-right:solid 1px;">-->
    <!--    <div class="option-div">A</div>-->
    <!--    <div class="option-div">B</div>-->
    <!--    <div class="option-div">C</div>-->
    <!--    <div class="option-div">D</div>-->
    <!--</div>-->

    <?php //} else { ?>
    <!--<div style="width:280px;border-left:solid 1px;border-right:solid 1px;">    -->
    <!--    <p class="option-div">A</p>-->
    <!--    <p class="option-div">B</p>-->
    <!--    <p class="option-div">C</p>-->
    <!--    <p class="option-div">D</p>-->
    <!--</div>-->

    <?php //}} ?>

<!--</div>-->