Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 18.117.184.236
<?php
include ("../database.php");
$query = "select x.fappno, if( ifnull(x.fcategory,'') = '', 'GM', x.fcategory) as fcategory, x.fhk, x.frank
from entstudadm x inner join entoptions y on x.fappno = y.fappno
where ifnull(fpaystatus,'') = 'success'
and ifnull(fappstatus,'') <> '' group by x.fappno
order by frank limit 10";
$result = mysqli_query($conn,$query);
echo '<style>
table{
width:100%;
table-layout: fixed;
}
</style>
<table style="text-align: left;width: 100%;" border="1" cellpadding="10" cellspacing="0">
<thead style = "">
<tr style = "background-color:#8acc51">
<th width="5%" align="center"><b>Sl. No.</b></th>
<th width="10%" align="center"><b>App. No.</b></th>
<th width="15%" align="left"><b>Name</b></th>
<th width="25%" align="left"><b>College</b></th>
<th width="25%" align="left"><b>Degree</b></th>
<th align="left"><b>Region</b></th>
<th align="left"><b>Category</b></th>
<th align="center"><b>Allotment No.</b></th>
<th align="center"><b>Rank</b></th>
</tr>
</thead>
</table>
<table style="text-align: left;width: 100%;" border="1" cellpadding="10" cellspacing="0">
<tbody>';
$slno = 1;
while($row = mysqli_fetch_assoc($result)) {
$query = "select fappno, fcollcode, fdegree from entoptions where fappno = '{$row['fappno']}' order by fpriority desc";
$result1 = mysqli_query($conn,$query);
while($row1 = mysqli_fetch_assoc($result1)) {
$query = "select fdegree, fcollcode, fpendseats from entseatmatrix
where fcollcode = '{$row1['fcollcode']}' and fdegree = '{$row1['fdegree']}' and freserve = 'NHK' and fcatcode = 'GM'";
$result2 = mysqli_query($conn,$query);
$seatmat1 = mysqli_fetch_assoc($result2);
if($seatmat1['fpendseats'] > 0 ) {
allotSeat($row['fappno'], $row1['fdegree'], $row1['fcollcode'], 'GM', 'NHK', $conn, $row['frank']);
continue;
} else if(strtoupper($row['fcategory']) != 'GM') {
$query = "select fdegree, fcollcode, fpendseats from entseatmatrix
where fcollcode = '{$row1['fcollcode']}' and fdegree = '{$row1['fdegree']}' and freserve = 'NHK' and fcatcode = '{$row['fcategory']}'";
$result3 = mysqli_query($conn,$query);
$seatmat2 = mysqli_fetch_assoc($result3);
if($seatmat2['fpendseats'] > 0 ) {
allotSeat($row['fappno'], $row1['fdegree'], $row1['fcollcode'], $row['fcategory'], 'NHK', $conn, $row['frank']);
continue;
}
}
if (strtoupper($row['fhk']) == 'YES') {
$query = "select fdegree, fcollcode, fpendseats from entseatmatrix
where fcollcode = '{$row1['fcollcode']}' and fdegree = '{$row1['fdegree']}' and freserve = 'HK' and fcatcode = 'GM'";
$result4 = mysqli_query($conn,$query);
$seatmat3 = mysqli_fetch_assoc($result4);
if($seatmat3['fpendseats'] > 0 ) {
allotSeat($row['fappno'], $row1['fdegree'], $row1['fcollcode'], 'GM', 'HK', $conn, $row['frank']);
continue;
}
}
if (strtoupper($row['fhk']) == 'YES' && strtoupper($row['fcategory']) != 'GM') {
$query = "select fdegree, fcollcode, fpendseats from entseatmatrix
where fcollcode = '{$row1['fcollcode']}' and fdegree = '{$row1['fdegree']}' and freserve = 'HK' and fcatcode = '{$row['fcategory']}'";
$result5 = mysqli_query($conn,$query);
$seatmat4 = mysqli_fetch_assoc($result5);
if($seatmat4['fpendseats'] > 0 ) {
allotSeat($row['fappno'], $row1['fdegree'], $row1['fcollcode'], $row['fcategory'], 'HK', $conn, $row['frank']);
continue;
}
}
}
$query = "select x.fappno, y.fname, concat(x.fdegree,' - ', d.fdescpn) as degree,
concat(x.fcollcode, ' - ', c.fcollname) as college, x.fcatcode,
x.freserve, x.fallotno, x.frank from entseatallot x inner join entstudadm y on x.fappno = y.fappno
inner join entdeg d on x.fdegree = d.fdegree inner join entcoll c on x.fcollcode = c.fcollcode
where x.fappno = '{$row['fappno']}'";
$res = mysqli_query($conn,$query);
$seatallot = mysqli_fetch_assoc($res);
echo "<tr>
<td width='5%' align='center'>{$slno}</td>
<td width='10%' align='center'>{$seatallot['fappno']}</td>
<td width='15%' align='left'>{$seatallot['fname']}</td>
<td width='25%' align='left'>{$seatallot['college']}</td>
<td width='25%' align='left'>{$seatallot['degree']}</td>
<td align='center'>{$seatallot['freserve']}</td>
<td align='center'>{$seatallot['fcatcode']}</td>
<td align='center'>{$seatallot['fallotno']}</td>
<td align='center'>{$seatallot['frank']}</td>
</tr>";
flush();
ob_flush();
$slno++;
}
function allotSeat($fappno, $allotdeg, $allotcoll, $allotcat, $allotres, $conn, $rank) {
$query = "select fdegree, fcollcode, freserve, fcatcode from entseatallot where fappno = '{$fappno}'";
$result3 = mysqli_query($conn,$query);
$count = mysqli_num_rows($result3);
if($count > 0) {
$seat_allot = mysqli_fetch_assoc($result3);
$query = "delete from entseatallot where fappno = '{$fappno}'";
$result4 = mysqli_query($conn,$query);
$query = "update entseatmatrix set fpendseats = ifnull(fpendseats,0) + 1, fallotseats = ifnull(fallotseats,0) - 1
where fdegree = '{$seat_allot['fdegree']}' and fcollcode = '{$seat_allot['fcollcode']}'
and freserve = '{$seat_allot['freserve']}' and fcatcode = '{$seat_allot['fcatcode']}'";
$result5 = mysqli_query($conn,$query);
$query = "update entoptions set freserve = '', fcatcode = ''
where fdegree = '{$seat_allot['fdegree']}' and fcollcode = '{$seat_allot['fcollcode']}'
and fappno = '{$fappno}'";
$result7 = mysqli_query($conn,$query);
}
// echo "$fappno -- $allotdeg -- $allotcoll -- $allotcat -- $allotres";
$insert = "insert into entseatallot(fappno, fdegree, fcollcode, freserve, fcatcode, frank, fallotdate, fallotround)
values('{$fappno}', '{$allotdeg}', '{$allotcoll}', '{$allotres}', '{$allotcat}', '{$rank}', now(), 0)";
$result6 = mysqli_query($conn,$insert);
$query = "update entseatmatrix set fpendseats = ifnull(fpendseats,0) - 1, fallotseats = ifnull(fallotseats,0) + 1
where fdegree = '{$allotdeg}' and fcollcode = '{$allotcoll}'
and freserve = '{$allotres}' and fcatcode = '{$allotcat}'";
$result7 = mysqli_query($conn,$query);
$query = "update entoptions set freserve = '{$allotres}', fcatcode = '{$allotcat}'
where fdegree = '{$allotdeg}' and fcollcode = '{$allotcoll}'
and fappno = '{$fappno}'";
$result7 = mysqli_query($conn,$query);
}
mysqli_close($conn);
?>
|