<?php
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../index.php'; </script>";
 return;
}
$cname=$_REQUEST[cname];
include("../opendb.php");
$brnchtp=$_REQUEST[brnchtp];
$tbl="advamt".$brcode.$user;
mysqli_query($db,"drop table $tbl"); 
if($brnchtp=='pur')
{
    $sq=mysqli_query($db,"select distinct suplier from sparepurchase where brcode='$brcode' order by suplier");  
    print "<option value='select'>-select-</option>";
    while($rw=mysqli_fetch_array($sq))
    {?>
        <option value='<? echo $rw[0] ?>'><? echo $rw[0] ?></option>
    <?}
}
if($brnchtp=='spr')
{
    $sq=mysqli_query($db,"select distinct customer from spareinvoice where brcode='$brcode' order by customer");  
    print "<option value='select'>-select-</option>";
    while($rw=mysqli_fetch_array($sq))
    {?>
        <option value='<? echo $rw[0] ?>'><? echo $rw[0] ?></option><?
    }
}
?>
