<?php

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

$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);
$admin = $_SESSION["admin_" . $dbname];
$success = false;

$party = $_REQUEST['party'];

if (isset($_REQUEST["party"])) {

    $query = "SELECT `transporter` FROM `accmast` WHERE accode='$party'";

    $result = mysqli_query($conn, $query)or die(mysqli_error($conn));
    $r = mysqli_fetch_assoc($result);
    $query2 = "SELECT code, `name` FROM `transport` WHERE code='$r[transporter]'";

    $result2 = mysqli_query($conn, $query2)or die(mysqli_error($conn));
    $r2 = mysqli_fetch_assoc($result2);

    Echo "<option value='$r2[code]' selected>$r2[name]</option>";

    $gtran = mysqli_query($conn, "SELECT `code`,`name` FROM `transport` WHERE `code`!='' ORDER by `name`")or die(mysqli_error($conn));
    while ($trans = mysqli_fetch_array($gtran)) {
        Echo "<option value='$trans[code]'>$trans[name]</option>";
    }
}