<?php
date_default_timezone_set('Asia/Kolkata');
$phone = $_GET['sid'];
$servername = "localhost";
$username = "avitac_user26";
$password = "h5*4ge2HToIK";
$dbname = "avitac_wifi";
$conn = mysqli_connect($servername, $username, $password, $dbname);
if (!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}
$sql5= "select * from student_reg where id='$phone'";
$retval = mysqli_query($conn,$sql5);
$found=0;
while($row = mysqli_fetch_assoc($retval))
{
    $name = $row['StudentName'];
	$found=1;
//create html of the data
ob_start();
?>
<style>
table {
border-collapse: collapse;
width: 100%;
}
th {
text-align: center;
padding: 3px;
font-size:14px;
font-weight:bold;
}
	
td {
padding: 3px;
font-size:14px;
}
	h1, h2, h3, h4, h5, h6, td, th, table, p, ul, li, label 
{
	font-family: Consolas, "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", Monaco, "Courier New", "monospace";
}
</style>
<div style="margin: 15px; padding:5px; margin-top: 15px;">
<p align="center"><img src="../users/avit_logo.jpg"></p>
<hr style="padding: 0 !important; margin: 0 !important; border: 1px solid black;" />
	<p align="center" style="font-size: 14px; margin-bottom: 2px !important; margin-top: 4px !important;"><strong>DEPARTMENT OF ICT- WIFI REGISTRATIONS (AV CAMPUS)</strong></p>
<div class="clear" style="clear: both;"></div>
<div width="78%" style="float: left">
<table>
<?php
		echo'
	<tr><th align="left">Student Name</th><td>:</td><td>'.$row['StudentName'].'</td></tr>
	<tr><th align="left">Register No</th><td>:</td><td>'.$row['RegisterNo'].'</td></tr>
	<tr><th align="left">Academic Year</th><td>:</td><td>'.$row['AcademicYear'].' / Semester- '.$row['Semester'].'</td></tr>
	<tr><th align="left">Department</th><td>:</td><td>'.$row['StuDepartment'].'</td></tr>
		';
	?>
	<tr><th align="left">College</th><td>:</td><td><?php echo $row['College'] ; ?></td></tr>
	<tr><th align="left">Email Id</th><td>:</td><td><?php echo $row['Email']; ?></td></tr>
	<tr><th align="left">Phone Number</th><td>:</td><td><?php echo $row['Phone']; ?></td></tr>
	</table>
	</div>

	<div width="20%" style="float: right">
	<p align="right" style="text-align: right; float: right; font-size: 12px;">Ref No: <?php echo $row['RefNo']; ?></p>
	<p align="right" style="text-align: right; float: right; font-size: 12px;">Date: <?php echo $row['Date']; ?></p>
    </div>
    	 <div width="45%" style="float: left">
        <p align="left" style="text-align: left; float: left; font-weight: bold; font-size: 14px;">Username:  <?php echo str_replace("-","",$row['RefNo']); ?></p>
        </div>
     <div width="45%" style="float: left">
        <p align="left" style="text-align: left; float: left; font-weight: bold; font-size: 14px;">Password: </p>
        </div>
	<div style="margin-top: 40px;" width="100%">
		<div style="float: left; width: 25%">
		<p align="center" style="font-size: 12px;"><strong><?php echo("$name"); ?></strong><br/>Student</p>
	</div>
	<div style="float: left; width: 23%">
		<p align="center" style="font-size: 12px;"><strong>FA / HoD</strong></p>
	</div>
	<div style="float: left; width: 24%">
		<p align="center" style="font-size: 12px;"><strong>Warden</strong><br/></p>
	</div>
	<div style="float: left; width: 25%">
		<p align="center" style="font-size: 12px;"><strong>Mr. Vinothkannan U</strong><br/>ICT</p>
	</div>
	<hr style="border: 1px dashed #000000;"/>
</div>
</div>
        <div style="margin: 15px; padding:5px; margin-top: 5px;">
<p align="center"><img src="../users/avit_logo.jpg"></p>
<hr style="padding: 0 !important; margin: 0 !important; border: 1px solid black;" />
	<p align="center" style="font-size: 14px; margin-bottom: 2px !important; margin-top: 4px !important;"><strong>DEPARTMENT OF ICT- WIFI REGISTRATIONS (AV CAMPUS)- <em>for Office use only</em></strong></p>
<div class="clear" style="clear: both;"></div>
<div width="78%" style="float: left">
<table>
<?php
		echo'
	<tr><th align="left">Student Name</th><td>:</td><td>'.$row['StudentName'].'</td></tr>
	<tr><th align="left">Register No</th><td>:</td><td>'.$row['RegisterNo'].'</td></tr>
	<tr><th align="left">Academic Year</th><td>:</td><td>'.$row['AcademicYear'].' / Semester- '.$row['Semester'].'</td></tr>
	<tr><th align="left">Department</th><td>:</td><td>'.$row['StuDepartment'].'</td></tr>
		';
	?>
	<tr><th align="left">College</th><td>:</td><td><?php echo $row['College']; ?></td></tr>
	<tr><th align="left">Email Id</th><td>:</td><td><?php echo $row['Email']; ?></td></tr>
	<tr><th align="left">Phone Number</th><td>:</td><td><?php echo $row['Phone']; ?></td></tr>
	</table>
	</div>
	<div width="20%" style="float: right">
	<p align="right" style="text-align: right; float: right; font-size: 12px;">Ref No: <?php echo $row['RefNo']; ?></p>
	<p align="right" style="text-align: right; float: right; font-size: 12px;">Date: <?php echo $row['Date']; ?></p>
    </div>
     <div width="45%" style="float: left">
        <p align="left" style="text-align: left; float: left; font-weight: bold; font-size: 14px;">Username:  <?php echo str_replace("-","",$row['RefNo']);?></p>
        </div>
     <div width="45%" style="float: left">
        <p align="left" style="text-align: left; float: left; font-weight: bold; font-size: 14px;">Password: </p>
        </div>
	<div style="margin-top: 40px;" width="100%">
			<div style="float: left; width: 25%">
		<p align="center" style="font-size: 12px;"><strong><?php echo("$name"); ?></strong><br/>Student</p>
	</div>
	<div style="float: left; width: 23%">
		<p align="center" style="font-size: 12px;"><strong>FA / HoD</strong></p>
	</div>
	<div style="float: left; width: 24%">
		<p align="center" style="font-size: 12px;"><strong>Warden</strong><br/></p>
	</div>
	<div style="float: left; width: 25%">
		<p align="center" style="font-size: 12px;"><strong>Mr. Vinothkannan U</strong><br/>ICT</p>
	</div>
	<hr style="border: 1px dashed #000000;"/>
</div>
</div>
<?php
}
?>
	
<?php 
        $body = ob_get_clean();

        $body = iconv("UTF-8","UTF-8//IGNORE",$body);

        include("../mpdf/mpdf.php");
        $mpdf=new \mPDF('c','A4','','' , 0, 0, 0, 0, 0, 0); 

        //write html to PDF
        $mpdf->WriteHTML($body);
 
        //output pdf
        $mpdf->Output($name.'.pdf','D');
?>