<?php

require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include('includes/function.php');

$zdb = $_SESSION["zdbyear_" . $dbname];

mysqli_select_db($conn, $zdb);

$shopwk = $_POST['shopwk'];
$selectedparty = $_POST['selectedparty'];

$showpwkcond = '';

if (!empty($shopwk)) {
    $showpwkcond = "AND `transporter`='$shopwk'";
}

echo "<option value=''>Select Customer</option>";

$qry = mysqli_query($conn,"SELECT `accode`,`name` FROM `accmast` WHERE `grpcode` = '010' $showpwkcond ORDER BY `name`") or die(mysqli_error($conn));

while($row = mysqli_fetch_array($qry)) {

    $selected = ($selectedparty == $row['accode']) ? 'selected' : '';
    echo "<option value='$row[accode]' $selected>$row[name]</option>";
}
?>