<?php
include_once"config.php";
$e = mysqli_query($con, "select * from emirate where status = 1 order by name");

$sp = mysqli_query($con, "select special_category.*, add_special_category.name as nam from special_category 
inner join add_special_category on add_special_category.id = special_category.name
where special_category.status = 1 group by special_category.name order by add_special_category.name");
?>

<div id="area " style="margin-top:45px">
<section>
<h2><em><?= $Special_title; ?></em></h2>
<div class="col-12" style="margin-bottom:40px;">
<table border="0" cellpadding="7" width="100%" cellspacing="0">
<thead>
<tr>
<td width="25%">Categories</td>
<?php $ee = array(); while($en = mysqli_fetch_array($e)){ $ee[] = $en['id']; ?>
<td width="10%"><?= $en['name'];?></td>
<?php } ?>
</tr>
</thead>
<tbody>
<?php while( $s = mysqli_fetch_array($sp)){ ?>
<tr>
<td width="25%"><?=  $s['nam'];  $name = $s['name']; ?></td>

<?php 
foreach($ee as $es ){  $pid = $es;
?>
<?php $spc = mysqli_query($con, "select * from special_category where  pid='$pid' and name = '$name' ");
if($spc->num_rows > 0){
	while($spe = mysqli_fetch_array($spc)){ ?>
<td><?= $spe['value']; ?></td>
<?php }}else{ ?>
<td> - </td>
<?php }} ?>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</section>
</div>
