将Mysql行值分配给同一PHP文件中的另一个查询

I would like to assign a query table value to another query in a same php file. For an example $pin_Value this value will be used for my second query in the page. This variable will be used in html too..

how to assign $pin_Value value to my second query?

kindly see the comment code for further info.

<?php
    error_reporting(0);
    include('config.php');
    $table_content = "";
    $table_content2 = "";
    $pin_Value = "";
    $po_Value = "";
    $dist_Value = "";
    $qry = "SELECT * FROM pincode_data where poName='" . $_GET['po']."' ORDER BY postalDivision ASC";
    $pind = mysql_fetch_array($pinCode);
    $result = mysql_query($qry) or die (mysql_error());
    while($row=mysql_fetch_array($result)) 
        {
            $pin_Value = $row['pinCode'];
            $po_Value = $row['postOffice'];
            $dist_Value = $row['districtName'];
            $state_Value = $row['stateName'];
            $table_content .= "<tr><td>Pincode:</td><td><a href='pinview.php?pin=" . $row['pinCode'] . "'>".$row['pinCode'] . "</a></td></tr>";
            $table_content .= "<tr><td>Office Name:</td><td><a href='poview.php?po=" . $row['postOffice'] . "'>".$row['postOffice'] . "</a></td></tr>"; 
            $table_content .= "<tr><td>District:</td><td><a href='../district.php?dist=" .$row[districtName] . "'> ".$row['districtName'] . " </a></td></tr>";
        } 
            mysql_close();
            $pin_Value = $row['pinCode']; // this value to be assigned to another query

    $qry2 = "SELECT DISTINCT postOffice FROM pincode_data WHERE pinCode ='" . $pin_Value . "'"; // here is the issue
    $result2 = mysql_query($qry2);
    while($row = mysql_fetch_array($result2))
        {
            $table_content2 .= "<li><a href='districtview.php?dist=".$row['postOffice']."'> ".$row['postOffice']."</a></li>";
        }

    mysql_close();
?>

Inside your 1st query there may be more than one result for $row['pinCode'] so the best practice is that try to make an array suppose $pincode and store all values in $pincode array inside while loop then try to use forach loop for $pincode and inside foreach loop use your query or in second query try to use ( IN ) Clause in your query.Hope this will help you.

remove

$pin_Value = $row['pinCode'];

after

mysql_close();

You have already define $pin_value inside while loop.